Imagine that you have a number of tests that work on a site that requires you to log in and move to a certain page. Or imagine that you need to have a test that requires you to be on a certain page. In these two situations the quickest way to find out which page you are on and then move to the correct one if need be, is to start testing. This is to make sure that we follow one of the major tenants of test automation, in that you always start from a known place. Let us see this in an example:
Create a new Java class in IDEA:
Import the relevant Selenium Packages.
Create the setup() and teardown() method. I prefer the JUnit 4 style of tests and will show code samples with the annotations.
We need to check that the page is on the correct page. For this we will use the selenium.getTitle to see the page title and then if incorrect move to the chapter(Locators)link. We do this because navigating to page is slower than checking the page's title or any other calls to the page already loaded.
We need to then validate that it is correct and then work accordingly. The following is a code snippet of how we can do this:
Create the rest of the test to check that items are on the page.
What just happened?
We have just seen how we can check if something is what the test is expecting.If it is, the test will carry on as we expect. If it isn't what we expect, we can move our test to the correct page and then carry on with that page. We will see that if you log into the @Before, you may not start your tests.
Now let's have a look at how we can make more tests maintainable by splitting areas out into other methods.
Selenium Related Interview Questions
|SILK TEST Interview Questions||QTP Interview Questions|
|JMeter Interview Questions||Automation Testing Interview Questions|
|Software testing Interview Questions||JUnit Interview Questions|
|TestNG Interview Questions||SAP Testing Interview Questions|
|Selenium WebDriver Interview Questions||Selenium IDE Interview Questions|
|QUnit Testing Interview Questions||Performance Testing Interview Questions|
|Hadoop Testing Interview Questions|
Getting Started With Selenium Ide
Overview Of Selenium Webdriver
Working With Webdriver
Getting Started With Selenium Grid
Advanced User Interactions
Working With Html5
Migrating From Remote Control To Webdriver
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.