This Section describes how to run your Test cases on different browsers.
Few Simple steps Using TestNG :)
Step 1: Create your Script. Using TestNG annotations. Define parameters (using @Parameters) for taking input value i.e, which browser should be used for Running the Test
Step 2: Create a TestNG XML for running your script
Step 3: Configure the TestNG XML for passing parameters i.e, to tell which browser should be used for Running the Test
Step 4: Run the TestNG XML which can pass the appropriate browser name to the Script such that the Test Case is executed in a specified browser
Programatically this can be Done as follows:
Step 1:
Step 2 & Step 3: The below XML is configured to run the Test Case in Firefox, Chrome and IE browser in sequential manner
Step 4:
Run the above XML as TestNG Suite from Eclipse IDE as shown below.
Few Simple steps Using TestNG :)
Step 1: Create your Script. Using TestNG annotations. Define parameters (using @Parameters) for taking input value i.e, which browser should be used for Running the Test
Step 2: Create a TestNG XML for running your script
Step 3: Configure the TestNG XML for passing parameters i.e, to tell which browser should be used for Running the Test
Step 4: Run the TestNG XML which can pass the appropriate browser name to the Script such that the Test Case is executed in a specified browser
Programatically this can be Done as follows:
Step 1:
package atu.multibrowser;
import
org.openqa.selenium.By;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
import
org.openqa.selenium.ie.InternetExplorerDriver;
import
org.testng.annotations.AfterClass;
import
org.testng.annotations.BeforeClass;
import
org.testng.annotations.Parameters;
import
org.testng.annotations.Test;
public class MultiBrowserTest {
private WebDriver driver;
// Configure for multi
browser drivers
@Parameters("browser")
@BeforeClass
public void beforeTest(String
browser) {
if
(browser.equalsIgnoreCase("firefox")) {
driver = new FirefoxDriver();
}
else if
(browser.equalsIgnoreCase("chrome")) {
// Set Path for the
executable file
System.setProperty("webdriver.chrome.driver",
"D:\\chromedriver.exe");
driver = new ChromeDriver();
}
else if
(browser.equalsIgnoreCase("ie")) {
// Set Path for the
executable file
System.setProperty("webdriver.ie.driver", "D:\\IEDriverServer.exe");
driver = new
InternetExplorerDriver();
}
else {
throw new
IllegalArgumentException("The Browser Type is Undefined");
}
// Open App
driver.get("http://demo.opensourcecms.com/wordpress/wp-login.php");
}
@Test
public void login() throws InterruptedException
{
// Enter UserName
driver.findElement(By.id("user_login")).clear();
driver.findElement(By.id("user_login")).sendKeys("admin");
// Enter Password
driver.findElement(By.id("user_pass")).clear();
driver.findElement(By.id("user_pass")).sendKeys("demo123");
// Click on Submit
button
driver.findElement(By.id("wp-submit")).submit();
}
@AfterClass
public void afterTest() {
try {
driver.quit();
}
catch (Exception e) {
driver = null;
}
}
}
Step 2 & Step 3: The below XML is configured to run the Test Case in Firefox, Chrome and IE browser in sequential manner
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE suite
SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite"
parallel="none">
<test name="FirefoxTest">
<parameter name="browser"
value="firefox" />
<classes>
<class name="atu.multibrowser.MultiBrowserTest"
/>
</classes>
</test>
<test name="ChromeTest">
<parameter name="browser"
value="chrome" />
<classes>
<class name="atu.multibrowser.MultiBrowserTest"
/>
</classes>
</test>
<test name="IETest">
<parameter name="browser"
value="ie" />
<classes>
<class name="atu.multibrowser.MultiBrowserTest"
/>
</classes>
</test>
</suite>
/***********************************************************************/
Enhancing your TestNG xml for running the Test Case on Different browsers Simultaneously. Speeding up the execution process :)
Using the feature provided by TestNG for Parallel Executions. Set the"parallel" attribute to "tests" so that the all the three browser tests can be executed Simultaneously.
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE suite
SYSTEM "http://testng.org/testng-1.0.dtd">
<!--Change The Parallel attribute for parallel Execution-->
<suite name="Suite"
parallel="tests">
<test name="FirefoxTest">
<parameter name="browser"
value="firefox" />
<classes>
<class name="atu.multibrowser.MultiBrowserTest"
/>
</classes>
</test>
<test name="ChromeTest">
<parameter name="browser"
value="chrome" />
<classes>
<class name="atu.multibrowser.MultiBrowserTest"
/>
</classes>
</test>
<test name="IETest">
<parameter name="browser"
value="ie" />
<classes>
<class name="atu.multibrowser.MultiBrowserTest"
/>
</classes>
</test>
</suite>
This is one short and quick way of setting up Multiple Browser Testing :)
nice work :)
ReplyDelete:)
DeleteCan we USE ur AUT reports for this test suite execution?????
ReplyDeleteHey AUT - I found this comes under suite folder thanks
DeleteIts ATU !!!
Delete#AT
is it possible to have 2 suite's in single xml file or i need to have separate for each set .
ReplyDeleteAccording to TestNG documentation, you can call multiple suite files in a single suite file.
Delete#AT
For Single test(I mean for single class inside the test), the above testng will work fine but not for multiple classes inside the test
ReplyDeleteexample:
Issue: Chrome browser stops execution once the Firefox opens
Example :
Deleteclasses>
class name="atu.multibrowser.MultiBrowserTest_1" />
class name="atu.multibrowser.MultiBrowserTest_2" />
/classes>
Note:I removed the "<" since I was not able to see after publish
Hi Pradeep,
DeleteThe post you referred explains more about multi browser tests - TestNG can also run methods in parallel. Please refer to TestNG documentaion.
#AT
For IE I am getting error:
ReplyDeleteorg.openqa.selenium.NoSuchElementException: Unable to find element with id == user_login (WARNING: The server did not provide any stacktrace information)
Seems that it's wrong locator for user_login field in IE. Open your website in IE and check path to this field.
DeleteI am get the same error when i launch 3 diff browsers like IE , FF , Chrome browsers the execution happens only on FF and rest of the two will be just still - hence we end up unable to find element errors. Btw I also checked that the locator is correct on IE / FF / chrome (its consistent).
DeleteAutomation Tester, good sample! Thank you =) How do you think, it will work with relative path to chromedriver.exe? I want to load my script to server and don't want care about strong path to drivers.
ReplyDeleteIt should work fine ! having the exe files relative to your project folder structure.
Delete#AT
Hi,
ReplyDeleteI'm getting below error , please help me on this.
Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones.
Thanks,
Anjaneyulu Vujani
you need to set the security zones to same (either checked or unchecked) in IE. Go To Internet Options, under security tab, set them to equal for all the zones.
Delete#AT
This information which you provided is very much useful for us.It was very interesting and useful for qa online training.We also providing qa online training institute in worldwide.
ReplyDeleteHi, am unable to run the suite,, can u help me please..
ReplyDeleteHow to get screenshot when we come across any failure in AUT report ?
ReplyDeletethanks for the steps. - Selenium Automation Testing Framework
ReplyDeleteThank you very much..i was keep on looking for this kind of example till evening, At last i got it thank you very much..
ReplyDeleteGreat Explanition
How to get screenshot when we come across any failure in AUT report ?
ReplyDeleteThank you. As you said short and quick. I would say it is awesome.
ReplyDeleteHi,
ReplyDeleteI am following the same method for performing Cross browser testing where
in the xml file i have mentioned parallel = "tests" and thread-count =
"3" but, the main problem what i am facing is say i have configured for 3
browsers (ff /ie / chrome) all the 3 browsers open and load the and URL but
only my FF browser will be performing the execution rest of the two
will not do anything. So could you please help me how to achieve
parallel execution.
BTW my browser versions are FF38.5 , IE 11 , Chrome49
Hi,
ReplyDeleteI have ran a cross browser scenario on FF, Chrome and IE. After execution while i try to view the report, I have spotted 3 runs out of which Run 1 and Run 2 are not displaying any content with error page displayed as "Your file was not found, It may have been moved or deleted."
Run 3 came up with the result of the execution of final browser among the three (Only the result of IE).
Can you please suggest a possible way by which i will be able to view the report of all the browsers (IE, Chrome and FF) using ATU?
how to run this sample ...please describe step by step
ReplyDeleteHi,
ReplyDeleteThanks for providing sample project. :)
Nice Information about multi browser My sincere thanks for sharing this post Please Continue to share this post
ReplyDeleteSelenium Training in Chennai
really nice blog has been shared by you. before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
ReplyDeleteselenium training in chennai
Hi, I am really happy to found such a helpful and fascinating post that is written in well understandable manner enhance me to learn quickly… Thanks.. Software Testing Training in Chennai | Selenium Training in Chennai
ReplyDeleteHi, I am really happy to found such a helpful and fascinating post that is written in well understandable manner enhance me to learn quickly… Thanks..
ReplyDeleteSelenium Training in Bangalore
This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.I really like this topic. Python Online Training
ReplyDeleteLearn Python Online
ReplyDeleteYou've made some good points there. I looked on the internet for more information about this
Mainframe Training In Chennai | Hadoop Training In Chennai | ETL Testing Training In Chennai
Hi,
ReplyDeleteI'm getting below error , please help me on this.
Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value for all zones.
software testing training online
Great information thanks a lot for the detailed articleThat is very interesting I love reading and I am always searching for informative information like this.
ReplyDeleteOnline Robot Framework Training
I would like to say that this blog really convinced me to update my knowledge about the technology you talk about. Thanks,very good post.
ReplyDeleteSelenium Training Chennai
software testing selenium training
selenium testing training in chennai
Selenium Training in T Nagar
Selenium Training in OMR
Very impressive thanks for sharing
ReplyDeleteVMware Training in Chennai
DevOps Training in Chennai
DevOps Certification in Chennai
This excellent website truly has all of the info I wanted concerning this subject and didn’t know who to ask.
ReplyDeleteJava Training in Bangalore
Advanced Java Training in Bangalore
ReplyDeleteYour info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
If you are looking for any Big data Hadoop Related information please visit our website Big Data Hadoop Training In Bangalore page!
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
ReplyDeleteDigital Marketing Certification Training
AWS Certification Training
Python Certification Training
Selenium Training
Data Science Certification Training
DevOps Certification Training
I like your more content. I'm read this article is such a nice blog.
ReplyDeletePython Training in Chennai
Python Training in Bangalore
Python Training in Hyderabad
Python Training in Coimbatore
Python Training
python online training
python flask training
python flask online training
Very interesting blog. Learn the automation testing concept very well.Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well.
ReplyDeleteDevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
Wow I can say that this is another great article as expected of this blog.Bookmarked this site.Thanks for sharing.Keep sharing more blogs like this.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training
There's no indication that's the case. Looking at Twitter's public repositories on Github , Scala is still, by far, the most common language used. ... stuhood: Twitter is not moving away from Scala. Scala continues to grow at a faster rate internally then any other language, and is ~50% of Twitter's backend codebase.
ReplyDeleteJava training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
This information which you provided is very much useful for us.It was very interesting and useful..
ReplyDeleteAWS Course in Chennai
AWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn.
ReplyDeleteacte chennai
acte complaints
acte reviews
acte trainer complaints
acte trainer reviews
acte velachery reviews complaints
acte tambaram reviews complaints
acte anna nagar reviews complaints
acte porur reviews complaints
acte omr reviews complaints
Thank you for the informative post. It was thoroughly helpful to me. Keep posting more such articles and enlighten us.
ReplyDeleteWeb Designing Training in Bangalore
Web Designing Course in Bangalore
Web Designing Training in Hyderabad
Web Designing Course in Hyderabad
Web Designing Training in Coimbatore
Web Designing Training
Web Designing Online Training
Thanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you...
ReplyDeletepython training in chennai
python course in chennai
python online training in chennai
python training in bangalore
python training in hyderabad
python online training
python training
python flask training
python flask online training
python training in coimbatore
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeleteCyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course |
CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course
ReplyDeleteExcellent Blog I like your blog and It is very informative. Thank you
Puppet Course Online
selenium online training
Linux Online Training
selenium trainings
ReplyDeletesql server dba training
Testing tool training
The Blog contains the effective and attractive information’s and thanks for the blog.
ReplyDeleteJava Training Institute in Chennai
JAVA Training Institute in Bangalore
I started reading your post from the beginning, and it was quite interesting to read. I appreciate you providing such a nice blog, and I hope you continue to update it on a regular basis.
ReplyDeleteadvanced java online training
Simply try to say ones content material could as daze. This fathomability while your eloquent is extremely perfect and I could think youon an expert for this count. Google Earth Pro Free Key high-ecological components nearby close to than your settlement set aside in me to control off when your ongoing day have adequate confirmation to kid support changed by using fundamentally basically not pretty weblog message. thankful to you stacks loads of nearby near you ought to go upon the eye-getting amass the cycle wrapped up.
ReplyDeleteGood Night Quotes For Friends ... Part of me was wishing today would never end! Hanging out with you makes me feel young again. Good night friend of mine. I lookGood Night Friends Quotes
ReplyDeleteA great blog on multi browser testing using selenium software.
ReplyDeleteslot siteleri
ReplyDeletekralbet
betpark
tipobet
mobil ödeme bahis
betmatik
kibris bahis siteleri
poker siteleri
bonus veren siteler
VA6L
betmatik
ReplyDeletekralbet
betpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
V7SE2E
شركة تسليك مجاري بالاحساء dFLr3AfIp5
ReplyDeleteشركة مكافحة بق الفراش بالخبر 9IyTGHojBi
ReplyDelete