1| Download Chromedriver 2.9 and IEDriverserver
3| Edit testng.xml as shown below,
testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" verbose="3" parallel="tests" thread-count="5">
<test name="Test on Firefox">
<parameter name="browser" value="Firefox"/>
<classes>
<class name="package.classname"/>
</classes>
</test>
<test name="Test on Chrome">
<parameter name="browser" value="Chrome"/>
<classes>
<class name="package.classname"/>
</classes>
</test>
<test name="Test on InternetExplorer">
<parameter name="browser" value="InternetExplorer"/>
<classes>
<class name="package.classname"/>
</classes>
</test>
<test name="Test on Safari">
<parameter name="browser" value="Safari"/>
<classes>
<class name="package.classname"/>
</classes>
</test>
</test>
<test name="Test on Opera">
<parameter name="browser" value="Opera"/>
<classes>
<class name="package.classname"/>
</classes>
</test>
</suite> <!-- Suite -->
Snippet
@BeforeTest
@Parameters({"browser"})
public void setUp(String browser) throws MalformedURLException
{
if (browser.equalsIgnoreCase("Firefox"))
{
System.out.println("Running Firefox");
driver = new FirefoxDriver();
baseUrl = "http://xyz.com";
}
else if (browser.equalsIgnoreCase("chrome"))
{
System.out.println("Running Chrome");
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
driver = new ChromeDriver();
baseUrl = "http://xyz.com";
}
else if (browser.equalsIgnoreCase("InternetExplorer"))
{
System.out.println("Running Internet Explorer");
System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");
DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); //If IE fail to work, please remove this and remove enable protected mode for all the 4 zones from Internet options
driver = new InternetExplorerDriver(dc);
baseUrl = "http://xyz.com";
}
Note:-
1| There are drawbacks in SafariDriver
Here, I have used,
Safari | 5.0.3 (7533.19.4)
Selenium | 2.35
OS | Windows Vista
# SafariDriver won't work properly in Windows 7
# SafariDriver does not support interacting with modal dialogs
# Cannot navigate forwards or backwards in browser history and more...
2| OperaDriver doesn't support Opera browser versions 13 and above
# Make sure the location of opera.exe under, %PROGRAMFILES%\Opera\opera.exe; If not, then try to locate the execution file using Capabilities
else if (browser.equalsIgnoreCase("safari"))
{
System.out.println("Running Safari");
driver = new SafariDriver();
baseUrl = "http://xyz.com";
}
else if (browser.equalsIgnoreCase("opera"))
}else if (browser.equalsIgnoreCase("opera"))
{
System.out.println("Running Opera");
// driver = new OperaDriver(); --Use this if the location is set properly | see note #2 below--
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("opera.binary", "C://Program Files (x86)//Opera//opera.exe");
capabilities.setCapability("opera.log.level", "CONFIG");
driver = new OperaDriver(capabilities);
// driver = new OperaDriver(); --Use this if the location is set properly | see note #2 below--
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("opera.binary", "C://Program Files (x86)//Opera//opera.exe");
capabilities.setCapability("opera.log.level", "CONFIG");
driver = new OperaDriver(capabilities);
baseUrl = "http://xyz.com";
}
Note:-
1| There are drawbacks in SafariDriver
Here, I have used,
Safari | 5.0.3 (7533.19.4)
Selenium | 2.35
OS | Windows Vista
# SafariDriver won't work properly in Windows 7
# SafariDriver does not support interacting with modal dialogs
# Cannot navigate forwards or backwards in browser history and more...
2| OperaDriver doesn't support Opera browser versions 13 and above
# Make sure the location of opera.exe under, %PROGRAMFILES%\Opera\opera.exe; If not, then try to locate the execution file using Capabilities
Thanks, Sams. It would be better if you post the above for Mac OS X also.
ReplyDeleteExpecting that post soon..
Thank you. Keep up your work.
Sure Pal; Keep you updated shortly.
DeleteCheers!
Sams
Thank you Sam's, it was easy to implement for project i'm working.
ReplyDeleteYou're Welcome :)
DeleteHi Prasanth,
ReplyDeleteI am using selenium wedriver+IE8. When i running the scripts with this combination is not working. The IE8 browser flicker and shake sometimes so it's not finding the elements.Please tell me your suggestions.
^I am having the same issue with webdriver+ie8 - the browser window flickers and shakes around - does anyone have any idea about this?
ReplyDeleteI am running the xml file for cross broswer, it works fine for firefox and chrome, but does not work for IE11 and Safari 5.1.7, please advise me asap as I have to give demo to my team.
ReplyDeleteHere is my xml file ..I tried giving the Thread.sleep(2000); command that maybe it will help.
ReplyDeleteFor IE, it brings up the browser http://localhost:7737/ and with message as This is the initial start page for the WebDriver server.
and it pops up the safari browser as http://localhost:36839/connect.html?url=ws%3A%2F%2Flocalhost%3A36839 with message as SafariDriver Launcher
please help me...
Thread.sleep(2000);
Thread.sleep(2000);
Don't know why my code is not readable.....it did not print .....
ReplyDeleteyeezys
ReplyDeletehermes belt
air jordan
a bathing ape
golden goose outlet
kyrie irving shoes
yeezy boost 350 v2
golden goose
jordan shoes
stephen curry shoes