1

I am trying to write a temporary mail script using selenium and I want to get the highlighted text in the image below.

enter image description here

The mail doesnt come up in the html:

<input id="mail" type="text" onclick="select(this);" data-original-title="Your Temporary Email Address" data-placement="bottom" data-value="Loading" class="emailbox-input opentip" readonly="">

I have been trying this script:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\chromedriver.exe")
driver.get("https://temp-mail.org/en/")  # loading page
wait = WebDriverWait(driver, 20)  # defining webdriver wait
print(wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'input-box-col'))).text())

But it gets this error:

C:\Users\fkahd\PycharmProjects\cryptodata\sanbox3.py:7: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\chromedriver.exe")
Traceback (most recent call last):
  File "C:\Users\fkahd\PycharmProjects\cryptodata\sanbox3.py", line 11, in <module>
    print(wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'input-box-col'))).text())
TypeError: 'str' object is not callable

I know that I can simply bypass this by clicking on the copy button on the site and then execute a function that prints my clipboard, but I think that I could usee this information for future projects on how to get this text.

1 Answer 1

1

There is no text() method but text is a WebElement attribute.

Effectively, your line of code will be:

wait = WebDriverWait(driver, 20)  # defining webdriver wait
print(wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'input-box-col'))).text) 
Sign up to request clarification or add additional context in comments.

Comments

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.