简体   繁体   中英

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: http://imgur.com/a/6OIgm )

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

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"

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM