Selenium
WebElement gmailLink = driver.findElement(By.linkText("GMail"));
WebElement username = driver.findElement(By.id("username"));
// Enter something to search for
element.sendKeys("Selenium testing tools cookbook");
// Now submit the form. WebDriver will find
// the form for us from the element
element.submit();
https://sites.google.com/a/chromium.org/chromedriver/
We can also specify a path externally through the
https://www.simple-talk.com/dotnet/asp.net/getting-started-with-ui-test-automation/
https://www.ravellosystems.com/blog/review-5-modern-test-tools-ui/
WebElement gmailLink = driver.findElement(By.linkText("GMail"));
WebElement username = driver.findElement(By.id("username"));
// Enter something to search for
element.sendKeys("Selenium testing tools cookbook");
// Now submit the form. WebDriver will find
// the form for us from the element
element.submit();
color.selectByVisibleText("Black");
color.deselectByVisibleText("Black");
double-click:
WebElement message = driver.findElement(By.id("message"));
// Verify color is Blue
assertEquals("rgba(0, 0, 255, 1)",
message.getCssValue("background-color"));
Actions builder = new Actions(driver);
builder.doubleClick(message).perform();
// Get the search textbox
WebElement searchField = driver.findElement(By.name("q"));
searchField.clear();
// Enter search keyword and submit
searchField.sendKeys("selenium webdriver");
searchField.submit();
browser navigation
WebElement resultLink = driver.findElement(By.linkText("Selenium WebDriver"));
resultLink.click();
new WebDriverWait(driver, 10).until(ExpectedConditions
.titleIs("Selenium WebDriver"));
assertEquals("Selenium WebDriver", driver.getTitle());
driver.navigate().back();
new WebDriverWait(driver, 10).until(ExpectedConditions
.titleIs("selenium webdriver - Google Search"));
assertEquals("selenium webdriver - Google Search", driver.getTitle());
driver.navigate().forward();
alert box:
driver.findElement(By.id("simple")).click();
// Optionally we can also wait for an Alert box using the WebDriverWait
new WebDriverWait(driver, 10)
.until(ExpectedConditions.alertIsPresent());
// Get the Alert
Alert alert = driver.switchTo().alert();
// Get the text displayed on Alert
String textOnAlert = alert.getText();
// Check correct message is displayed to the user on Alert box
assertEquals("Hello! I am an alert box!", textOnAlert);
// Click OK button, by calling accept method
alert.accept();
// Enter some value on Prompt Alert box
alert.sendKeys("Foo");
// Click OK button, by calling accept method
alert.accept();
Pop-up window
// There is no name or title provided for Chat Page window
// We will iterate through all the open windows
// and check the contents to find out if it's Chat window
try {
for (String windowId : driver.getWindowHandles()) {
driver.switchTo().window(windowId);
// We will use the page source to check the contents
String pageSource = driver.getPageSource();
if (pageSource.contains("Configuration - Online Chat")) {
// Check the page for an element displaying a expected
// message
assertTrue(driver.findElement(By.tagName("p")).getText()
.equals("Wait while we connect you to Chat..."));
// Find the Close Button on Chat Window and close the window
// by clicking Close Button
driver.findElement(By.id("closebutton")).click();
break;
}
}
} finally {
// Switch back to the parent browser window
driver.switchTo().window(currentWindowId);
}
WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. ChromeDriver is a standalone server which implements WebDriver's wire protocol for Chromium. ChromeDriver is available for Chrome on Android and Chrome on Desktop (Mac, Linux, Windows and ChromeOS).
–Dwebdriver.chrome.driver
option using Maven command line optionshttps://www.simple-talk.com/dotnet/asp.net/getting-started-with-ui-test-automation/
https://www.ravellosystems.com/blog/review-5-modern-test-tools-ui/
public void test01() throws Exception, FindFailed { driver.get("www.xyz.com"); try{ sikuliObject.click("C:\\workspace\\project\\images\\1.png", 0); //Clicking an image sikuliObject.type("C:\\workspace\\project\\images\\search.png", "hello"); //Inserting values into a text field } catch(FindFailed e) { e.printStackTrace(); }