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