Friday, October 31, 2014

In this tutorial, We will learn how to go forward to the next web page. Forward To The Next Web Page 1. Go to "http:// www.facebook. com". 2. Click on forgot password link. 3. Come back to "http:// www.facebook. com". 4. Now forward to the next web page (i.e forgot password page). google_ad_client = "ca-pub-8489590936844748"; google_ad_slot = "7087636712"; google_ad_width =...
Suppose we are in login page and then we clicked on forget password link. Now we are in forget password page and we want to go back to the login page. Let's see how can we go back to the previous web page. driver.navigate().back() - This command is used to go previous page. google_ad_client = "ca-pub-8489590936844748"; google_ad_slot = "7087636712"; google_ad_width = 336; google_ad_height...
Sometimes we need to refresh the current web page to reload or to get the new dynamic value.  driver.navigate().refresh() - This command is used to refresh the current page. Refresh Current Web Page Example google_ad_client = "ca-pub-8489590936844748"; google_ad_slot = "7087636712"; google_ad_width = 336; google_ad_height = 280; import org.openqa.selenium.By; import...

Tuesday, October 28, 2014

In this tutorial, I will show you how to resolve WebDriver Exceptions. 1. Firefox - You may have faced org.openqa.selenium.firefox.NotConnectedException error. To resolve this error, we need to download new version of Selenium. You can download Selenium from "http:// docs.seleniumhq. org/download/" and then...

Monday, October 27, 2014

In my earlier posts, we have learned WebDriver's Drivers, WebDriver's Commands. In this tutorial, we will learn how to navigate on specific page or URL. 1. get(String URL) - This method will load a web page of given URL in the current browser. Example: driver.get(“www.google.com”); 2. driver.navigate().to(String URL) - This method will load a web page of given URL in the current browser. Example:...
Let's see how to list excepted exceptions that a test method can throw. If the test method throw no exception or throw other than excepted exceptions then the test will be marked a failure. In the below example, there are two test methods - 1. exceptionTest - This test method result will be pass because the...

Saturday, October 25, 2014

In this tutorial, We will see how to set maximum time for test case execution. If the test case takes more time than the specified time to finish then the TestNG will market it as failed. To set maximum time for test case execution, we use timeOut attribute of @Test annotation. google_ad_client = "ca-pub-8489590936844748"; ...
In this tutorial, we will see how to ignore test case. Sometimes, We need to ignore test cases. In this example, We will ignore WorkflowTest test case. TestNG comes with annotation @Test and attribute "enabled". We need to make enabled equal to false. google_ad_client = "ca-pub-8489590936844748"; ...

Thursday, October 23, 2014

In this tutorial, I will list out Selenium WebElement methods. WebElement in a web page is nothing but a text box, button, links, checkbox, radio button, table, window, frames etc. Selenium WebElement Methods  1. clear() - This method is used to clear the value of text box. Example: driver.findElement(By.name(“username”)).clear(); 2....
In this tutorial, I will list out Selenium WebElement locator. WebElement’s locators used to find all WebElements within a web page. Selenium WebElement Locator   1. findElements() - This method is used to find all WebElements within a web page with same locator. Example: List<WebElement>...
WebDriver is an interface in Selenium. WebDriver provides a set of methods that we use to automate web application for testing purpose. 1. get(String URL) - This method will load a web page of given URL in the current browser. Example: driver.get(“www.google.com”); 2. getCurrentUrl() – This method will...
Selenium WebDriver’s driver (i.e. browser driver) is required to make a direct calls to the browser using browser’s native support for automation. In selenium, FirefoxDriver, InternetExplorerDriver, ChromeDriver and HtmlUnitDriver is a class which implements WebDriver interface. Selenium WebDriver’s Driver...
TestNG provides “@Test” annotation along with attribute “dependsOnMethods”. There may be a requirement to make a test case to depends on other test cases. To make a test case to depends on other test cases, we need to use dependsOnMethods attribute with @Test annotation.  DependsOnMethods Testng Example  ...
We need to set priority of test cases to execute test case in a particular order. If we do not set priority of test cases then we are not sure the order of execution of test case (i.e. Logout test case may run or execute before Login test case). Steps to test an application 1. Login 2. Workflow 3. Logout...