HealYouDown
HealYouDown

Reputation: 156

Python3 (Selenium) can't locate password box

my current problem is that Python can't locate my password box.

<input class="stylepwd" name="pws" size="12" maxlength="12" onkeypress="return stEnter(event,this);" autocomplete="off" type="password">

Thats all i tried to do, but it always say it cant locate that box

element = driver.find_element_by_name('pws')
element = driver.find_element_by_class_tag('stylepwd')
element = driver.find_element_by_id('') #Yea, thats obviously not working ^^'
element.send_keys('mypassword')

Maybe there's another way I can type in that password. As soon as the site is loading, the cursor is in the box. Can I do anything with this? (Thats the site: https://i.sstatic.net/QM7eE.jpg)

Python code: https://pastebin.com/3ydHwDkH

Upvotes: 0

Views: 123

Answers (2)

so1989
so1989

Reputation: 327

If it is in iframe, try

iframe = driver.find_elements_by_tag_name("iframe")[0]
driver.switch_to_frame(iframe)

then

element = driver.find_element_by_name('pws')

Upvotes: 0

Satish Prakash Garg
Satish Prakash Garg

Reputation: 2233

You can do something like this :

elem = driver.find_element_by_xpath('//input[@class="stylepwd"]')

This will give you the element input with class="stylepwd"

Upvotes: 1

Related Questions