Python Selenium Analog swipe operation

Source: Internet
Author: User

Selenium.webdriver provides all Webdriver implementations and currently supports Firefox, Phantomjs, Chrome, IE and remote

The Quit () method exits the browser, and the close () method simply closes the page, but if only one page is open, the close () method also exits the browser

Using remote Webdriver

Before using remote Webdriver, you need to start selenium server with the following command:

Java-jar Selenium-server-standalone-2.x.x.jar

After the selenium server runs, you will see the following information:

15:43:07.541 Info-remotewebdriver instances should connect To:http://127.0.0.1:4444/wd/hub

The above information indicates the address of the connection Seleniumserver Http://127.0.0.1:4444/wd/hub, the following is the instance code:

 fromSelenium.webdriver.common.desired_capabilitiesImportdesiredcapabilities Driver=Webdriver. Remote (Command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities=desiredcapabilities.chrome) Driver=Webdriver. Remote (Command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities=Desiredcapabilities.opera) Driver=Webdriver. Remote (Command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities=DESIREDCAPABILITIES.HTMLUNITWITHJS)

Desiredcapabilities is a dictionary type, so you can redefine the value of the dictionary in addition to using the default values, as follows:

Driver =Webdriver. Remote (Command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities={'Browsername':'Htmlunit',                           'version':'2',                          'javascriptenabled': True})

Send_keys (keys. RETURN) #键盘返回键
Send_keys (Keys.arrow_down) #键盘向下的箭头

#Coding:utf-8 fromSeleniumImportWebdriver fromSelenium.webdriver.common.action_chainsImportActionchains#introduction of Actionchains Mouse Operation class fromSelenium.webdriver.common.keysImportKeys#introducing the Keys class operationImportTime Browser=Webdriver. Chrome () Browser.get ('http://www.baidu.com')  Print 'now maximize your browser'Browser.maximize_window () article= Browser.find_element_by_link_text (U'Zhou Bihua: What does it mean to have a ghost inside the academy? ') actionchains (browser). move_to_element (article). Perform ()#move the mouse over here, but it's not good here.actionchains (browser). Context_click (article). Perform () Time.sleep (5) Browser.quit ()

Python Selenium Analog swipe operation

Related Article

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.