Sunday, 2 March 2014

Run cross browser tests | Selenium | Python | Ruby


Note|  Text in Blue [#PYTHON] and RED [#RUBY] can be edited or mentioned important for the entire blog. All the posts are practically done by me.

1| Download Chromedriver 2.9IEDriverserver, and phantomjs
2| Extract the zipped folders and locate them in code [highlighted in #blue].


Chrome

import os

from selenium import webdriver

chromedriver = "C://Test//chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
self.driver = webdriver.Chrome(chromedriver)

self.driver.get("http://python.org/")

or|

self.driver = webdriver.Chrome("C://Test//chromedriver.exe")


Internet Explorer

self.driver = webdriver.Ie("C://IEDriverServer.exe")
self.driver.get("http://python.org/")


Firefox

self.driver = webdriver.Firefox()

self.driver.get("http://python.org/")


PhantomJS

self.driver = webdriver.PhantomJS("
C://phantomjs.exe")
self.driver.get("http://python.org/")

or|

1| Open cmd prompt
2| Locate the folder C:\Python27\Scripts in cmd and enter
brew install phantomjs

self.driver = webdriver.PhantomJS()
self.driver.get("http://python.org/")




1| Download Chromedriver 2.9 and IEDriverserver
2| Extract the zipped folders and add them in Environment Variables path.
My Computer > (right click) properties > Advanced system settings > Environment Variables
3| Click path under system variables and choose Edit.
4| Paste the Driver locations.



Chrome

require "selenium-webdriver"
@driver = Selenium::WebDriver.for :chrome



Internet Explorer

@driver = Selenium::WebDriver.for :ie
OR|
@driver = Selenium::WebDriver.for :internet_explorer


Firefox

@driver = Selenium::WebDriver.for :firefox



Note:- 
1| 'brew' doesn't work on Windows

4 comments:

  1. Thanks for the great information in your blog Selenium Training in Chennai

    ReplyDelete
  2. It was very nice blog to learn about SAP HR.Thanks for sharing new things.SAP HR

    ReplyDelete
  3. I just want to say I’m new to blogs and seriously loved this web site. You really have great stories. Regards for revealing your web site.

    Selenium Training in Chennai

    ReplyDelete