Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97778

Retrieve the attribute from a WebDriver Element

$
0
0

I am looking to retrieve the text of this web element

<span class="address what_to_copy">thisemail@changes.com</span></h1>

The element is a changing email. How can integrate get_attribute().
Currently, Selenium gives me:

<selenium.webdriver.remote.webelement.WebElement (session="163f197aa61b4cfbc9962b5b746aa225", element="0.1826725098009514-1")>

From the code below

#coding: utf-8
import time
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options


class WebDriver:

    def __init__(self):
        self.setup()
        self.extractor()
        self.teardown_module()

    def setup(self):
        self.options = Options()
        self.options.headless = True
        self.driver = webdriver.Chrome('/Users/user/Documents/docs/chromedriver', options=self.options)


    def extractor(self):
        self.driver.get('https://getnada.com/')
        print('\n')
        sauce = self.driver.page_source
        element = self.driver.find_element(By.CSS_SELECTOR, 'span.address.what_to_copy')
        print(element.text)


    def teardown_module(self):
        self.driver.quit()

page = WebDriver()
page.driver

Viewing all articles
Browse latest Browse all 97778

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>