1

I am looking to retrieve the text of this web element

<span class="address what_to_copy">[email protected]</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

1 Answer 1

1

text contains the value of the element

element = self.driver.find_element(By.CSS_SELECTOR, 'span.address.what_to_copy')
print(element.text)
Sign up to request clarification or add additional context in comments.

2 Comments

Sometimes its the simplest things #facepalm. I humbly thank you 😳
@mexitaw Happy to help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.