Python 3.4: Chromedrive, IEDriverServer, geckoDriver,

Source: Internet
Author: User
Tags seleniumhq selenium webdriver interview questions

Python 3.4: Chromedrive, IEDriverServer, geckoDriver,

Import sys; import time; import OS; # from huoche import PythonTickt; from splinter. browser import Browser; # from splinter. driver. webdriver import BaseWebDriver, WebDriverElement; # from splinter import Browser; from selenium import webdriver; from selenium. webdriver. common. keys import Keys; import selenium. webdriver. chrome. service as service; import traceback; from selenium. webdriver import Chrome; from seleniu M. webdriver. chrome. options import Options; from pyvirtualdisplay import Display; ''' firepath = "C:/Program Files/Mozilla Firefox/"; browser = webdriver. firefox (firepath) browser. get ('HTTP: // www.yahoo.com ') assert 'yahoo' in browser. titleelem = browser. find_element_by_name ('P') # Find the search boxelem. send_keys ('seleniumhq '+ Keys. RETURN) browser. quit () ''' # browser-driven chrome http://chromedriver.storage.googl Eapis.com/index.html# https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver # https://github.com/mozilla/geckodriver/releases # Firefox driver geckodriver # http://selenium-release.storage.googleapis.com/index.html# http://selenium-release.storage.googleapis.com/index.html? Path = 3.8/# IE driver # https://sites.google.com/a/chromium.org/chromedriver/home#https://sites.google.com/a/chromium.org/chromedriver/getting-started#https://github.com/SeleniumHQ/selenium/tree/master/py#http://www.techbeamers.com/selenium-webdriver-python-tutorial/#service = service. service ('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe ') # service. start () # capabilities = {'chrome. binary ': 'C: /Program Files (x86)/Google/Chrome/application'} # driver = webdriver. remote (service. service_url, capabilities) # driver. get ('HTTP: // www.google.com/xhtml'); # time. sleep (5) # Let the user actually see something! # Driver. quit () executable_path = {'executable _ path': 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe '}; # ** executable_path # Open or abnormal # http://splinter.readthedocs.io/en/latest/api/driver-and-element-api.html # splinter. browser. browser (driver_name = 'Firefox ', * args, ** kwargs) path = 'C:/Program Files (x86)/Google/Chrome/Application /'; url = "https://kyfw.12306.cn/otn/leftTicket/init"; # huoche = huoche (); chrome # driver = webdriver. firefox (); # driver. get ("http://www.google.com/"); # create a new Firefox session ''' driver = webdriver. firefox (firepath) driver. implicitly_wait (30) driver. maximize_window () # navigate to the application home pagedriver. get ("http://www.google.com") # get the search textboxsearch_field = driver. find_element_by_id ("lst-ib") search_field.clear () # enter search keyword and submitsearch_field.send_keys ("Selenium WebDriver Interview questions") search_field.submit () # get the list of elements which are displayed after the search # currently on result page using find_elements_by_class_name methodlists = driver. find_elements_by_class_name ("_ Rm") # get the number of elements foundprint ("Found" + str (len (lists) + "searches :"); # iterate through each element and print the text that is # name of the searchi = 0for listitem in lists: print (listitem) I = I + 1 if (I> 10 ): break # close the browser windowdriver. quit () ''' # get the path of IEDriverServer # https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriveriepath= "C:/Python34/IEDriverServer.exe" dir = OS. path. dirname (_ file _) # ie_driver_path = iepath; # dir + "\ IEDriverServer.exe" # create a new Internet Explorer sessiondriver = webdriver. ie (ie_driver_path) driver. implicitly_wait (30) driver. maximize_window () # navigate to the application home pagedriver. get ("http://www.google.com") # get the search textboxsearch_field = driver. find_element_by_name ("q") # enter search keyword and submitsearch_field.send_keys ("Selenium WebDriver Interview questions") search_field.submit () # get the list of elements which are displayed after the search # currently on result page using find_elements_by_class_name methodlists = driver. find_elements_by_class_name ("r") # get the number of elements foundprint ("Found" + str (len (lists) + "searches :") # iterate through each element and print the text that is # name of the searchi = 0for listitem in lists: print (listitem) I = I + 1 if (I> 10 ): break # close the browser windowdriver. quit () ''' # get the path of ChromeDriverServerdir = OS. path. dirname (_ file _) chrome_driver_path = dir + "\ chromedriver.exe" # create a new Chrome sessiondriver = webdriver. chrome (chrome_driver_path) driver. implicitly_wait (30) driver. maximize_window () # navigate to the application home pagedriver. get ("http://www.google.com") # get the search textboxsearch_field = driver. find_element_by_name ("q") # enter search keyword and submitsearch_field.send_keys ("Selenium WebDriver Interview questions") search_field.submit () # get the list of elements which are displayed after the search # currently on result page using find_elements_by_class_name methodlists = driver. find_elements_by_class_name ("r") # get the number of elements foundprint ("Found" + str (len (lists) + "searches :") # iterate through each element and print the text that is # name of the searchi = 0for listitem in lists: print (listitem) I = I + 1 if (I> 10 ): break # close the browser windowdriver. quit () ''' browser = webdriver. chrome () # first tabbrowser. get ('HTTP:/reddit.com ') # second tabbrowser.exe cute_script ("window. open ('about: blank ', 'tab2'); ") browser. switch_to.window ("tab2") browser. get ('HTTP: // bing.com ') # Browser ("chrome", ** executable_path, fullscreen = True); # size = driver. manage (). window (). setSize (new Dimension (1024,768); # options = Options (); # options. add_argument ('-- lang = en-us'); # global browser; # browser = BaseWebDriver (); # browser. driver = Chrome (chrome_options = options); chrome_options = Options () chrome_options.add_argument ("-- headless") chrome_options.add_argument ("-- window-size = 1366,768") # https://sites.google.com/a/chromium.org/chromedriver/downloadschrome_driver = 'C: /Program Files (x86)/Google/Chrome/Application/'driver = webdriver. chrome (chrome_options = chrome_options, executable_path = chrome_driver) driver. get ("https://www.wikipedia.org/") english_link = driver. find_element_by_css_selector ("# js-link-box-en") english_link.click () d = Display (visible = 0, size = (800,600); d. start (); chrome_options = ChromeOptions () chrome_options.add_argument ('Disable-setuid-sandbox'); B = Browser ('chrome'); B. visit ('HTTP: // www.google.com '); B. quit (); d. stop (); options = Options () options. add_argument ("window-size = 1, 1"); browser = BaseWebDriver () browser. driver = Chrome (chrome_options = options) browser. visit ('https: // www.google.com ')

  

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.