selenium chromedriver usage

#selenium chrome usagehtml

environmentjava

  • win7
  • python2.7.11
  • selenium2.51

##1.Selenium support browser typepython

  • default : firefoxgit

  • chromegithub

  • IEweb

  • safarichrome

##2. chromedriver usageapi

###2.1 Download chromedriver here.python2.7

###2.2 Paste the chromedriver.exe file in "C:\Python27\Scripts" Folder.this

##3. Test ###3.1 start selenium grid hub you can follow my pre blog selenium grid2

###3.2 Code

options=webdriver.ChromeOptions()
	options.add_argument('--disable-logging')	
	driver=webdriver.Remote("http://localhost:4200/wd/hub",desired_capabilities=options.to_capabilities())

###3.3 run your script

if chrome is opening successfully,it works.

##4. Exception you might got this error message:

Caused by: java.lang.IllegalStateException: The path to the driver executable mu st be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

  1. check the chromedriver path is correct or not
  2. chromedriver not support your current chrome version.

##5. another usage

  1. no need to start selenium grid

  2. Code

capabilities = DesiredCapabilities.CHROME
 capabilities['loggingPrefs'] = {'browser':'ALL'}
driver = webdriver.Chrome(executable_path=chromedriver,desired_capabilities=capabilities)

##6. reference

  1. https://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium/25988106#25988106
相關文章
相關標籤/搜索