I am trying to write a temporary mail script using selenium and I want to get the highlighted text in the image below.
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" 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.
CodePudding user response:
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)