Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99014

Python Selenium webdriver locating element error

$
0
0

I am studying how to use Python Selenium to login a website "https://you.163.com/". However, hours past, I still fail. Error message is below: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='j-yx-mailLoginWrap']/iframe"}

Can anyone help to point out where is the error and how to fix it. Thank you.

def newlogin():
   b=webdriver.Chrome()
   b.get("https://you.163.com/")
   ele = b.find_element_by_xpath("//*[@class='j-yx-cp-topLogin']")
   ele.click()
   time.sleep(4)
   ele=b.switch_to.frame(b.find_element_by_xpath("//iframe[starts-with(@id, 'x-URS-iframe')]"))
   print("1")
   time.sleep(3)
   ele1 = b.find_element_by_xpath("//*[@id='j-yx-mailLoginWrap']/iframe")
   ele1.click()
   print("2")
   b.switch_to_frame(ele1)
   ele2 = b.find_element_by_xpath("//*[@class='j-inputtext dlemail']")
   print("3")
   ele2.send_keys("XXXXX@163.com")
   ele3 = b.find_element_by_xpath("//*[@class='j-inputtext dlpwd']")
   ele3.send_keys("XXXXX")
   ele4 = b.find_element_by_xpath("//*[@id='dologin']")
   ele4.click()

Viewing all articles
Browse latest Browse all 99014

Trending Articles