Inversion of control / Dependency injection — what is it?
Assume you depend on two or objects to create a functional representation of “Add to cart” implementation. This can be achieved traditionally via: create objects of all dependencies and...
Assume you depend on two or objects to create a functional representation of “Add to cart” implementation. This can be achieved traditionally via: create objects of all dependencies and...
Let’s create a simple multi-threaded program where every thread increments the shared count variable 4 times. So if there are two threads, after they finish count value should be...
Following code snippet demonstrates how to select an option from “AutoComplete” text field import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class...
Return type for “ExpectedConditions.xxxx()” is generally falls under following categories: Alert Boolean WebElement List WebDriver Object Following code snippet demonstrates usage and validation based on return type. (ExpectedCondition testing...
Following code snippet can be used to kill all running instances of Internet Explorer import java.io.IOException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class RerunAttemp { @Test public void...
Following code snippet can be used to details of link and their working / not working (broken) details on a page package practice; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL;...
In order to execute a script via two threads and three times total, we can use following code snippet import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.Test; public class...
following code snippet shows example of dependsOnMethods function import org.testng.annotations.Test; public class TestNGExample { @Test(groups = { “Automation” }) public void driver() { System.out.println(“Initialize Browser”); } @Test(dependsOnMethods = {...
Following code snippet can be used to resize a browser window in selenium import org.openqa.selenium.Dimension;import org.openqa.selenium.WebDriver;import org.openqa.selenium.firefox.FirefoxDriver;import org.testng.annotations.Test; public class testJavaScriptErrors { @Testpublic void testForFramesCount() throws InterruptedException {WebDriver driver...
Following generic code can be used to execute a JavaScript with Selenium WebdDriver import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class testJavaScriptErrors { @Test public void testForFramesCount()...