Web Automation using Selenium

I want to clear a text area for inserting something new. However, I am not able to do that.

I used the following command-

code_element=browser.find_element_by_xpath(’//*[@id=“file_div”]/textarea’)
code_element.clear()

But this is not working. Can you please tell me a way to do that, so that i can some new keys into that text area.

hey @LPLC0059,
can you please provide link to your code, so that i can have look and understand what the problem is.

Thank You and Happy Learning :slightly_smiling_face: .

Here is the link to my code-

hey @LPLC0059 ,
i just tried your code and it worked absolutely fine.
To understand the problem more better , can you please a recording of its run .
You can upload it on drive and share me the link.

I have sent you the link in mail. Please Check.

hey , i checked it .
Its basically doing this wrong due to getpass() , i am figuring it out why it is so.
Try with static values in code , like giving username and password in code itself , and not taking inputs.

It’s still not working.

hey @LPLC0059 ,
Sorry for such late reply.
At the point of where you get the text area element
after that add these code lines.

code_element.send_keys(keys.Keys.CONTROL + "a")
code_element.send_keys(keys.Keys.DELETE)

after this , read your code file to be submitted and write it in text area.

I hope this works .
Thank You. :slightly_smiling_face:

It’s showing an error.
NameError: name ‘keys’ is not defined

ohh sorry…
just add
from selenium.webdriver.common import keys

The error has gone, but the code snippet is still not clearing the text area.

hey @LPLC0059 ,
try this code https://ide.codingblocks.com/s/289408

and let me know if this works.

Still not working. Gives the same result that my code gives.

did you implemented the same code ?

kindly upload your code on github and share its link with me.
Let me know

  1. Python version you are working on.
  2. IDE you are working on , jupyter or any other ? ( although it doesn’t make any difference )

I’m using python-3.8.3 and Jupyter Notebook.
I’ve shared the GitHub link with you over mail, please check.
Thank you

After this command
browser.find_element_by_xpath('//*[@id="lang"]/option[15]').click()
add
import time
time.sleep(3)
and let me know does it works now.

This did not make any difference. But i got to know what is the error now. Since I’m using a MacBook Ctrl+a does not select the textbook, instead of that i should use Command+a. It’s working fine now. Anyways, thank you!

ohh yes.

Actually it will, sometimes there might be case , that your network might be a bit slow. At that time it will be useful.

Anyways ,at least your doubt is resolved now. That’s just you wanted to have.

Thank You and Happy Learning :slightly_smiling_face:.