Python Selenium first entry

Source: Internet
Author: User

Ubuntu python3.41. Install Selenium, PIP installation
Pip Install Selenium

2.selenium version 2.53.x

Try to download the selenium3 from the official website, but firefox to install the new geckodriver, the change back to 2.53.x.

The next study will be supplemented.

3. Start the sample exercise

A QQ Mailbox Login program was tested:

#-*-coding:utf-8-*- fromSeleniumImportWebdriver fromSelenium.webdriver.common.keysImportKeysImportTimedriver=Webdriver. Firefox () Driver.get ("http://mail.qq.com/")ifU"Login" inchDriver.title:Print("Login") Driver.switch_to.frame ("Login_frame") Elem= driver.find_element_by_id ('u') Elem.clear () Elem.send_keys (user name) Elem= driver.find_element_by_id ('P') Elem.clear () Elem.send_keys (password+Keys.return) driver.switch_to.default_content ()assertU"QQ" inchDriver.titlePrint(U'Login on it! ') Time.sleep (90) Driver.close ()
View Code

At first the user name password find_element can not find, and later found in an IFRAME, using switch to frame after the smooth find_element.

    Driver.switch_to.frame ("login_frame")

This is a small trap for selenium, and after it is done, almost all of the element has a method to check.

4. Proxy Verification

Firefox often pops up the verification window after using the auto agent. It's annoying, and I can't find a way to get selenium off.

Then installs the Firefox plugin Auto Auth, solves. :)

Selenium is very convenient to use, it is also quick to get started ...

Python Selenium first entry

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.