Selenium Python login 126 mailbox Error Record __python

Source: Internet
Author: User
Tags xpath selenium python

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.