0

I'm copying email every 10 minutes from https://10minutemail.pl/ and I want to paste it to email_elem element on another web site, using code below:

driver.get("https://10minutemail.pl/")
email2_elem = driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[1]/div[1]/div[1]/form[1]/div[1]/input[1]").text
time.sleep(2)
driver.get("https://www.instagram.com/")
time.sleep(2)
email_elem = driver.find_element_by_xpath("//input[@name='emailOrPhone']")
email_elem.clear()
email_elem.send_keys(email_elem.email2_elem)

Bu I get error:

AttributeError: 'WebElement' object has no attribute 'email2_elem'

1 Answer 1

2

The error is on this line:

email_elem.send_keys(email_elem.email2_elem)

, and it is exactly what it says - you have stored that text inside the (standalone) variable email2_elem, but are referencing it as if it is an attribute of another one, email_elem - which it is not.
Just change it to:

email_elem.send_keys(email2_elem)

, and it will work.

Sign up to request clarification or add additional context in comments.

4 Comments

I have 1 more problem when i try to paste it later code worka normaly but nothing appears. But when i copy other text with same method from somewhere else it works. What am i doing wrong?
What do you mean by "paste it later" and "copy other text"? Copy and paste are clipboard operations, while your code sample doesn't use it, it just gets a text and stores it in a variable.
I mean. When i try to get this email from 10 minutes mail and use it as shown. It's just doesn't appear
Ok, that's a different question, but still - it's either the xpath is not targeting the correct element, or - most likely, it's because you are trying to get the text of an <input> tag. As you, I presume, want to get the value that is where there, using text() is not the way to do it - you need to change that to .getAttribute("value")

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.