1. Ready to do a login 126 mailbox operation, with Firefox firebug view the user name box ID, password box ID is id= "auto-id-1491067388576"
Such a class, F5 refresh the browser, looked back at the User name box, password box ID is changed, so you can not use webdriver.get_element_by_id () positioning, the use of Webdriver.get_element_by_class_ Name (), the code is as follows
From selenium import Webdriver
Driver = Webdriver. Firefox ()
Driver.get ("http://www.126.com")
Driver.find_element_by_class_name ("J-inputtext dlemail"). Clear ()
Driver.find_element_by_class_name ("J-inputtext dlemail"). Send_keys ("username")
Driver.find_element_by_class_name ("J-inputtext dlpwd"). Clear ()
Driver.find_element_by_class_name ("J-inputtext dlpwd"). Send_keys ("password")
driver.find_element_by_id ("Dologin"). Click ()
Driver.quit ()
2. A run on the error, error Occurred:InvalidSelectorError:Compound class names not permitted compound class name is not allowed, classname parameters can only be a class, You cannot make a compound class name (that is, multiple classes separated by spaces).
3. Change the code above to XPath positioning: Driver.find_element_by_xpath ("//input[@class = ' j-inputtext dlemail ')", driver.find_element_by_ XPath ("//input[@class = ' j-inputtext dlpwd ']"), run or report selenium.common.exceptions.NoSuchElementException:Message: Unable to locate element: {"method": "XPath", "selector": "//input[@class = ' j-inputtext dlemail ']"}
4. Re-view the next 126.com home page, login in a frame iframe, to
Driver.get ("http://www.126.com") after adding a paragraph of driver.switch_to.frame ("X-urs-iframe") to normal positioning
Reference links 1:http://www.cnblogs.com/sylvia-liu/p/4469084.html
Reference links 2:http://www.cnblogs.com/zhengyihan1216/p/6095543.html