I have written a selenium test that clicks all links on a page. But my popup close code does not handle the popup and the test is discontinued.
I am on Selenium Java V2.53.1, TestNG and backend is browserstack.
This is the call stack, after the last page the popup appears and is not dismissed!
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
link: /
link2: /
link2: /articles
link: /articles
link2: /
This is my test method:
#Test
public void test_click_all_links() throws Exception {
String base_url = "https://infinite-taiga-25466.herokuapp.com";
driver.get(base_url);
//get all links with href that start with /
ArrayList<String> links = (ArrayList) ((JavascriptExecutor) driver).executeScript("return [...document.querySelectorAll(\"a[href^='/']\")].map(e=>e.getAttribute('href'))");
links.forEach(link->{
driver.get(base_url + link);
System.out.println("link: " + link);
//check here
try {
WebDriverWait wait = new WebDriverWait(driver, 5, 100);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
// Prints text and closes alert
//System.out.println(alert.getText());
alert.dismiss();
} catch (NoAlertPresentException | TimeoutException ex) {
//do nothing
};
Assert.assertNotEquals(title(), "The page you were looking for doesn't exist.");
//get all sublinks with href that start with /
ArrayList<String> sublinks = (ArrayList) ((JavascriptExecutor) driver).executeScript("return [...document.querySelectorAll(\"a[href^='/']\")].map(e=>e.getAttribute('href'))");
sublinks.forEach(link2->{
driver.get(base_url + link2);
System.out.println("link2: " + link2);
//check here
try {
WebDriverWait wait = new WebDriverWait(driver, 5, 100);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
// Prints text and closes alert
//System.out.println(alert.getText());
alert.dismiss();
} catch (NoAlertPresentException | TimeoutException ex) {
//do nothing
};
Assert.assertNotEquals(title(), "The page you were looking for doesn't exist.");
});
});
}
Without no clear understand how you're going pass authentication without username/password, page will not open in this case, code below will cancel authentication using page load timeout.
How to use basic authentication you can find here.
private WebDriver driver;
private WebDriverWait wait;
private JavascriptExecutor js;
private String baseUrl = "https://infinite-taiga-25466.herokuapp.com";
#BeforeMethod
public void setUp() {
driver = new ChromeDriver();
wait = new WebDriverWait(driver, 5, 100);
js = (JavascriptExecutor) driver;
}
public void closeAlert() {
try {
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.dismiss();
} catch (NoAlertPresentException | TimeoutException ignored) { }
}
#SuppressWarnings("unchecked")
public ArrayList<String> getLinks() {
return (ArrayList<String>) js.
executeScript("return [...document.querySelectorAll(\"a[href^='/']:not([href='/'])\")].map(e=>e.getAttribute('href'))");
}
#Test
public void clickAllLinks() {
driver.get(baseUrl);
ArrayList<String> links = getLinks();
links.forEach(link -> {
System.out.println("link: " + link);
driver.get(baseUrl + link);
closeAlert();
Assert.assertNotEquals(driver.getTitle(), "The page you were looking for doesn't exist.");
ArrayList<String> subLinks = getLinks();
subLinks.forEach(link2 -> {
System.out.println("link2: " + link2);
try {
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
driver.get(baseUrl + link2);
} catch (Exception ignore) {
System.out.println("Cancel authorization popup");
} finally {
driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
}
// On page loading timeout, authentication closed automatically.
// No need
//closeAlert();
Assert.assertNotEquals(driver.getTitle(), "The page you were looking for doesn't exist.");
});
});
}
I am stuck in a scenario, where user is allowed to rate the movie only once a day with same user credentials.
If user tried to rate the same movie or contract, error pop_up seen.
I want to Implement in a way, that if once any movie/contract is rated. The rating functionality should be skipped and Error pop should be Handled.
I am using Selenium eclipse 2017, Chrome browser 61.0 and Test-Ng
Please help in the same.
Thanks.
public class Ratings {
String driverPath = "F:/ChromeDriver/chromedriver.exe";
public WebDriver driver;
public Alert alert;
#BeforeTest
public void LaunchBrowser () throws InterruptedException {
System.out.println("WebBrowser open");
System.setProperty("webdriver.chrome.driver","F:/ChromeDriver/chromedriver.e
xe");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
#Test (priority = 1, alwaysRun = true)
public void HomePageUSA() throws InterruptedException {
driver.navigate().to("Https://us.justdial.com");
String expectedTitle = "Justdial US";
String actualTitle = driver.getTitle();
try
{
AssertJUnit.assertEquals(expectedTitle, actualTitle);
System.out.println("Test Passed");
}
catch (Throwable e)
{
System.out.println("Test Failed");
}
Thread.sleep(3000);
}
#Test (priority = 2, dependsOnMethods = {"HomePageUSA"})
public void Login() throws Exception{
Thread.sleep(3000);
driver.findElement(By.xpath("/html/body/div/div[1]/div[1]/div[1]/div/div/div
/div[4]/aside/div/span/a[1]")).click();
driver.findElement(By.id("inputPassword3")).clear();
driver.findElement(By.id("inputPassword3")).sendKeys("testing.testjd#gmail.c
om");
driver.findElement(By.id("exampleInputPassword1")).clear();
driver.findElement(By.id("exampleInputPassword1")).sendKeys("justdial");
driver.findElement(By.xpath("/html/body/div[4]/div[2]/div[1]/section/div/div
[1]/div/form/div[3]/div/button")).click();
Thread.sleep(1000);
String expectedTitle = "Justdial US";
String actualTitle = driver.getTitle();
try
{
Assert.assertEquals(expectedTitle, actualTitle);
System.out.println("Login Successful");
}
catch (Throwable e)
{
System.out.println("Login Failed");
}
Thread.sleep(1000);
driver.findElement(By.xpath(".//*[#id='us-jdnew-
wrapper']/div[1]/div/header/div/div[1]/a[2]")).click();
Thread.sleep(2000);
}
#Test (priority = 3)
public void Movies_Rating_page() throws Exception {
driver.findElement(By.xpath(".//*[#id='hotkeylnk106']/div[2]")).click();
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='main-
wrapper']/div/div/div[3]/div[2]/div/div[1]/div[1]/div/a/span/img")).click();
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='main-
wrapper']/div/div/div[2]/div[1]/ul/li[2]/span/a[2]/span[1]")).click();
Thread.sleep(3000);
driver.findElement(By.xpath(".//*
[#id='AlreadyRated']/div/div/div/section/div/a")).click();
System.out.println("Rating Page Redirection Successful");
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[#id='us-jdnew-
wrapper']/div/form/div/div/div/div[2]/span[2]/span[10]")).click();
Thread.sleep(1000);
driver.findElement(By.xpath(".//*[#id='us-jdnew-
wrapper']/div/form/div/div/div/div[3]/div[3]/textarea")).sendKeys("Very nice
movie, Must watch.");
Thread.sleep(1000);
driver.findElement(By.xpath(".//*[#id='us-jdnew-
wrapper']/div/form/div/div/div/div[3]/div[4]/button[2]")).click();
Thread.sleep(3000);
System.out.println("Rating Successfully Submitted");
You can create a method and tag that method in your test method as dependsOnMethods . You can achieve it like below (i tried to answer to the best based on the info provided)
The idea here is that when your rated condition is met isMovieRated should throw exception so that Movies_Rating_page() will be skipped by testNG ,otherwise isMovieRated just returns true and nothing should be skip.
#Test
public static boolean isMovieRated(String locator) {
//check in "if" below that element has already clicked or is equal to something. I used 'AlreadyClicked' just to
give an idea as I dont have your application information.
if (driver.findElement(By.xpath(locator).getText()=="AlreadyClicked"){
throw new RuntimeException();
}
else {
return true;
}
}
Now your Movies_Rating_page() will look like this
#Test (priority = 3,dependsOnMethods = { "isMovieRated" })
public void Movies_Rating_page() throws Exception {
public static String YourLocator = "/html/body/...."
Ratings.isMovieRated(YourLocator);
..
}
here is a link for more info on testNG dependsOnMethods
Note:
The code above is not tested.
If you are doing things other than checking rating in Movies_Rating_page() then you should separate those things because everything will be skipped when an exception is thrown.
Hope this helps.
I am getting "java.lang.NullPointerException" when I am trying to execute my test case based on POM.
The class BrowserFactory lets me choose a browser, the class Flipkart_Login based on POM stores all the element of that particular page and has a method for Valid_Login()
and finally Test_Flipkart_Login class - calls the Valid_Login() method for executon but when I try to execute this class, I get java.lang.NullPointerException.
Kindly advise!
FAILED: Flipkart_Login_Test
java.lang.NullPointerException
at DataProviders.ConfigDataProvider.getURL(ConfigDataProvider.java:31)
at TestCases.Test_Flipkart_Login.Flipkart_Login_Test(Test_Flipkart_Login.java:19)
public class ConfigDataProvider
{
static Properties pro;
public ConfigDataProvider()
{
File src = new File("C:\\Data\\Bimlesh\\Flipkart_HybridFramework\\Flipkart.Hybrid.FrameworkComplete\\Configuration\\Config.Properties");
try
{
FileInputStream fis = new FileInputStream(src);
pro = new Properties();
pro.load(fis);
} catch (Exception e)
{
System.out.println("The Config exception is :"+e.getMessage());
}
}
public static String getURL()
{
String URL = pro.getProperty("URL");
return URL;
}
public static String ChromePath()
{
String Chrome = pro.getProperty("Chromepath");
return Chrome;
}
public static String IEPath()
{
String IE = pro.getProperty("IEpath");
return IE;
}
}
public class BrowserFactory
{
static WebDriver driver;
public static WebDriver getBrowser(String BrowserName)
{
if(BrowserName.equalsIgnoreCase("Firefox"))
{
driver = new FirefoxDriver();
}
else if(BrowserName.equalsIgnoreCase("Chrome"))
{
System.setProperty("webdriver.chrome.driver", ConfigDataProvider.ChromePath());
driver = new ChromeDriver();
}
else if(BrowserName.equalsIgnoreCase("IE"))
{
System.setProperty("webdriver.ie.driver", ConfigDataProvider.IEPath());
driver = new InternetExplorerDriver();
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
return driver;
}
public void ShutDown(WebDriver driver)
{
driver.quit();
}
}
public class Flipkart_Login
{
WebDriver driver;
public Flipkart_Login(WebDriver driver)
{
this.driver=driver;
}
#FindBy(xpath="//a[text()='Log In']") WebElement Login_Click;
#FindBy(xpath="//input[#class='_2zrpKA' and #type='text']") WebElement Enter_Email;
#FindBy(xpath="//input[#class='_2zrpKA _3v41xv' and #type='password']") WebElement Enter_Pass;
#FindBy(xpath="//button[#type='submit' and #class='_3zLR9i _1LctnI _36SmAs']") WebElement Login_Button;
public void Valid_Login()
{
Login_Click.click();
Enter_Email.sendKeys("xxx#gmail.com");
Enter_Pass.sendKeys("xxx");
Login_Button.click();
}
}
public class Test_Flipkart_Login
{
WebDriver driver;
#Test
public void Flipkart_Login_Test()
{
driver = BrowserFactory.getBrowser("Firefox");
driver.get(ConfigDataProvider.getURL());
Flipkart_Login page1 = PageFactory.initElements(driver, Flipkart_Login.class);
page1.Valid_Login();
}
}
You have initialized Properties pro in the constructor of the COnfigDataProider but you are using a static call to getURL method from your test class. Thus pro will be null and not initialized. Remove static call and use the constructor or make pro to static and initialize in static block.
I am trying to implement a method 'waitForNewWindow' in Java using selenium WebDriver. This method is all about waiting to check if a new window is opened. If a new window is opened in the specified time, i need to return true, else return false.
public boolean waitForNewWindow(String target) {
try {
Thread.sleep(30000);
if(driver.switchTo().window(target)!=null) {
log.info("New window is opened");
return true;
}
}catch(Exception e) {
log.debug(e);
return false;
}
return true;
}
But here, I don't want to use thread.sleep(time). The waiting time needs to be specified as below:
WebDriverWait wait = new WebDriverWait(driver, TIMEOUT);
Moreover, in the above code, the control is switching to the new window, which is not expected. Can someone please provide your answers on how to implement my requirement?
the below mentioned code checks for the number of windows to appear with time out
public void waitForNumberOfWindows(final int length){
new WebDriverWait(driver, 30) {
}.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return driver.getWindowHandle().length()==length;
}
});
}
it will check for the expected number of windows to be present at that instance and will return true if the count matches with in the specified timeout(30 in above code)
You can not specify a timeout like you want. You have to use Thread.sleep().
Regarding your control moving to new window because of your below line the control is moving to new tab
driver.switchTo().window(target)
If you want to simply check if there is two windows open or not, you can write something like below
while( driver.getWindowHandle().length() != 2){
Thread.sleep(2000);
}
Finally got the implementation of waitForNewWindow method, using the WebDriverWait object as below:
try {
ExpectedCondition<Boolean> e = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver wd) {
if (wd.switchTo().window(newTarget) != null) {
log.info("New window is opened with the window id : "
+ newTarget);
driver.switchTo().window(parentHandle);
return true;
} else {
return false;
}
}
};
WebDriverWait wait = new WebDriverWait(driver, TIMEOUT);
if (wait.until(e)) {
log.info("the wait for the expected condition is successful");
return true;
}
} catch (Exception e1) {
log.debug(e1);
return false;
}
Tested the same and its working fine.
I am beginning to write a Test Automation Framework in Java (language that I am comfortable with) for my Web Application. Currently, it is entirely tested on UI. No Backend / API testing in near sight.
I plan to use Selenium Web Driver. This framework will support both Functional/Integration and Performance testing.
I am building with Open Source Solutions for the first time (over using tools like LoadRunner) and my needs are this framework will work with Continuous Integration tools like Jenkins/Hudson and an in-house Test Management tool for reporting results.
I searched for this specific scenario but could not find one. I know there will be numerous integrations, plug-ins, etc... that needs to be built. My question is can you provide some pointers (even good reads is OK) towards beginning to build this framework with Open source solutions ?
Selenium will allow you to automate all your web (browsers) actions
automations.
Junit/TestNG as the testing framework,
including their default reports system
Maven for the project
management and lifecycle (including test phase with surefire
plugin)
Jenkins is a good integration tool that will easily
run the setup above
Good luck!
I am giving here framework functions which reduces code very much
public TestBase() throws Exception{
baseProp = new Properties();
baseProp.load(EDCPreRegistration.class.getResourceAsStream("baseproperties.properties"));
// Firefox profile creation
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", ProxyType.AUTODETECT.ordinal());
profile.setPreference("browser.cache.disk.enable", false);
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port",8080);
driver = new FirefoxDriver(profile);
//System.setProperty("webdriver.ie.driver","E:\\Phyweb Webdriver\\IEDriverServer.exe");
//driver = new InternetExplorerDriver();
driver.manage().window().maximize();
}
//To find WebElement by id
public static WebElement FindElement(String id)
{
try
{
webElement= driver.findElement(By.id(id));
}
catch(Exception e)
{
Print(e);
}
return webElement;
}
//To find WebElement by name
public static WebElement FindElementByName(String name)
{
try
{
webElement= driver.findElement(By.name(name));
}
catch(Exception e)
{
Print(e);
}
return webElement;
}
//To find WebElement by Class
public static WebElement FindElementByClass(String classname)
{
try
{
webElement= driver.findElement(By.className(classname));
}
catch(Exception e)
{
Print(e);
}
return webElement;
}
//To get data of a cell
public static String GetCellData(XSSFSheet sheet,int row,int col)
{
String cellData = null;
try
{
cellData=PhyWebUtil.getValueFromExcel(row, col, sheet);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return cellData;
}
//To click a button using id
public static void ClickButton(String id,String label)
{
try
{
WebElement webElement= FindElement(id);
Snooze();
webElement.click();
PrintMessage(label+" is selected");
}
catch(Exception e)
{
Print(e);
}
}
//To click a button using class
public void ClickButtonByClass(String classname,String label)
{
try
{
WebElement webElement= FindElementByClass(classname);
Snooze();
webElement.click();
PrintMessage(label+" is selected");
}
catch(Exception e)
{
Print(e);
}
}
//To enter data into Textbox
public String editTextField(int rownum, int celnum,WebElement element ,XSSFSheet sheet,String Label)
{
XSSFRow row = sheet.getRow(rownum);
XSSFCell Cell = row.getCell(celnum);
String inputValue = Cell.getStringCellValue().trim();
element.clear();//To clear contents if present
try
{
element.sendKeys(inputValue);
String elementVal=element.toString();
if(elementVal.contains("password"))
{
PrintMessage("Password is entered");
}
else
{
PrintMessage("Value entered for "+Label+" is "+inputValue);
}
}
catch(Exception e){
Print(e);
//cv.verifyTrue(false, "<font color= 'red'> Failed due to : </font> "+e.getMessage());
}
return inputValue;
}
//To enter data into Textbox
public String editTextFieldDirect(WebElement element ,String text,String label)
{
element.clear();//To clear contents if present
try
{
element.sendKeys(text);
String elementVal=element.toString();
if(elementVal.contains("password"))
{
PrintMessage("Password is entered");
}
else
{
PrintMessage("Value entered for "+label+" is "+text);
}
}
catch(Exception e){
Print(e);
//cv.verifyTrue(false, "<font color= 'red'> Failed due to : </font> "+e.getMessage());
}
return text;
}
//To select Radio button
public void ClickRadioButton(String id)
{
try
{
WebElement webElement= FindElement(id);
Snooze();
webElement.click();
text=webElement.getText();
PrintMessage(text+" is selected");
}
catch(Exception e)
{
Print(e);
}
}
//To select Link
public void ClickLink(String id,String label)
{
try
{
ClickButton(id,label);
}
catch(Exception e)
{
Print(e);
}
}
//To Click an Image button
public void ClickImage(String xpath)
{
try
{
WebElement webElement= FindElement(id);
Snooze();
webElement.click();
text=GetText(webElement);
PrintMessage(text+" is selected");
}
catch(Exception e)
{
Print(e);
}
}
//Select a checkbox
public void CheckboxSelect(String id,String label)
{
try
{
WebElement webElement= FindElement(id);
Snooze();
webElement.click();
PrintMessage("Checkbox "+label+" is selected");
}
catch(Exception e)
{
Print(e);
}
}
//To select value in Combobox
public void SelectData(String id,String label,String cellval)
{
try
{
WebElement webElement= FindElement(id);
Snooze();
webElement.click();
String elementStr=webElement.toString();
int itemIndex=elementStr.indexOf("value");
if(itemIndex>-1)
{
int endIndex=elementStr.length()-3;
String item=elementStr.substring(itemIndex+7, endIndex);
if(cellval=="0")
{
PrintMessage(item+" is selected for "+label);
}
else
{
PrintMessage(cellval+" "+label+" is selected");
}
}
else
{
PrintMessage(cellval+" is selected for "+label);
}
}
catch(Exception e)
{
Print(e);
}
}
//To check if WebElement with id exists
public static boolean isExists(String id)
{
boolean exists = false;
driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
try
{
exists=driver.findElements( By.id(id) ).size() != 0;
}
catch (Exception e)
{
Print(e);
}
if(exists==true)
return true;
else
return false;
}
//To check if WebElement with name exists
public static boolean isExistsName(String name)
{
boolean exists = false;
driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
try
{
exists=driver.findElements( By.name(name) ).size() != 0;
}
catch (Exception e)
{
if(e.getMessage().contains("InvalidSelectorError"))
{
System.out.println("");
}
else
Print(e);
}
if(exists==true)
return true;
else
return false;
}
//Explicit wait until a element is visible and enabled using id
public void ExplicitlyWait(String id)
{
try
{
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.id(id)));
}
catch(Exception e)
{
Print(e);
}
}
//Explicit wait until a element is visible and enabled using classname
public void ExplicitlyWaitByClass(String classname)
{
try
{
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.className(classname)));
}
catch(Exception e)
{
Print(e);
}
}
//Explicit wait until a element is visible and enabled using id
public void ExplicitlyWaitSpecific(int sec,String id)
{
try
{
WebElement myDynamicElement = (new WebDriverWait(driver, sec))
.until(ExpectedConditions.presenceOfElementLocated(By.id(id)));
}
catch(Exception e)
{
Print(e);
}
}
//Snooze for 10 seconds
public static void Snooze()
{
try
{
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
catch(Exception e)
{
Print(e);
}
}
//Snooze for Secs
public static void SnoozeSpecific(int seconds)
{
try
{
driver.manage().timeouts().implicitlyWait(seconds, TimeUnit.SECONDS);
}
catch(Exception e)
{
Print(e);
}
}
//Sleep for milliSeconds
public static void Sleep(int milisec) throws InterruptedException
{
Thread.sleep(milisec);
}
//To get text using text()
public static String GetText(WebElement element)
{
try
{
text=element.getText();
}
catch(Exception e){
Print(e);
}
return text;
}
//To get text using getAttribute("value")
public static String GetTextAttribute(WebElement element)
{
try
{
text=element.getAttribute("value");
}
catch(Exception e){
Print(e);
}
return text;
}
//To Print error messages to both Console and Results file
public static void Print(Exception e)
{
Reporter.log("Exception is :"+e.getMessage());
System.out.println(e);
}
//To Print messages to both Console and Results file
public static void PrintMessage(String str)
{
Reporter.log(str);
System.out.println(str);
}
//To Print Blank row
public static void BlankRow()
{
Reporter.log(" ");
System.out.println(" ");
}
//To Print Sub header
public static void Header(String str)
{
BlankRow();
Reporter.log("***********************"+str+" Verifications***********************");
System.out.println("***********************"+str+" Verifications***********************");
BlankRow();
}
//To Print Sub header
public static void SubHeader(String str)
{
BlankRow();
Reporter.log("-----------------------"+str+" Verifications-----------------------");
System.out.println("-----------------------"+str+" Verifications-----------------------");
BlankRow();
}
So long as you have a command line for kicking off your framework and you report back using the xunit log format then you should be good for integration with any number of Continuous integration frameworks.
Your trade off on running a browser instance under load will be fewer virtual users per host and a very careful examination of your load generator resources under load. Don't forget to include monitoring API in your framework for system metrics under load and an auto evaluation engine related to SLA metrics acceptance to determine pass of fail criteria under load at a given load point.
We are begining to develop something very related to your needs; Java, Webdriver, Jenkins, Maven, etc. We are quite new to automation here, but still have good Java ressources.
We are builing our framework based on Tarun Kumar from www.seleniumtests.com.
He's got a lot of good videos from Youtube (sounds quality is not so good), and he manage to create something very user friendly, using PageObjects Pattern.
If you don't have any clue where to start, I would start from there.
Good luck!
I created a java library on the top of selenium which simplifies test automation of a website. It has an implicit waiting mechanism and is easy to use:
https://github.com/gartenkralle/web-ui-automation
Example:
import org.junit.Test;
import org.openqa.selenium.By;
import common.UserInterface;
import common.TestBase;
public class Google extends TestBase
{
private final static String GOOGLE_URL = "https://www.google.com/";
private final static By SEARCH_FIELD = By.xpath("//input[#id='lst-ib']");
private final static By AUTO_COMPLETION_LIST_BOX = By.xpath("//*[#id='sbtc']/div[2][not(contains(#style,'none'))]");
private final static By SEARCH_BUTTON = By.xpath("//input[#name='btnK']");
#Test
public void weatherSearch()
{
UserInterface.Action.visitUrl(GOOGLE_URL);
UserInterface.Action.fillField(SEARCH_FIELD, "weather");
UserInterface.Verify.appeared(AUTO_COMPLETION_LIST_BOX);
UserInterface.Action.pressEscape();
UserInterface.Action.clickElement(SEARCH_BUTTON);
}
}
Selenium WebDriver is surely a tool for UI automation and we use it extensively to do cross Browser testing on Cloud Solutions like Browser Stack.
Our use case let us build an open source Framework "omelet" built in Java using TestNG as test runner , which takes care of almost everything related to web-testing and leaves us to actually automated application rather than thinking about reports , parallel run and CI integration etc.
Suggestion, Contribution always welcome :)
Documentation over here and
Github link over here
Do remember to checkout 5 min tutorial on website
For Functional Regression test:
Selenium Webdriver - Selenium a Web based automation tool that automates anything and everything available on a Web page. you use Selenium Webdriver with JAVA.
Watij- Web Application Testing in Java
Automates functional testing of web applications through real web browsers.
TestProject - It supports for testing both web and Mobile (Android & iOS).
For Non-functional test:
Gatling- For performance testing and Stress testing
Apache JMeter - For Volume, Performance, Load & Stress testing
CI tool:
Jenkins- Jenkins provides continuous integration services for software development.
For Functional Regression test:
TestProject
Selenium
Cucumber : It's a BDD tool
For Non-functional: Performance and Load testing:
JMeter
Note: TestComplete is a very good commercial tool.