package learning;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
public class Dropdown {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://html.com/attributes/select-size/?utm_source=network%20recirc&utm_medium=Bibblio");
//Select dropdown by Select class
Select select = new Select(driver.findElement(By.xpath("//select")));
//select required item from the above dropdown
select.selectByValue("Lesser");
}
}
Showing posts with label automation testing. Show all posts
Showing posts with label automation testing. Show all posts
Friday, March 8, 2019
Select an Item from the drop-down in selenium webdriver
Labels:
automation,
automation testing,
coding,
development,
Java,
learning,
selenium,
testing,
web driver
Dealing with modal dialog in selenium Webdriver
package test.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class ModelDialog {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Mutturaj\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://html.com/input-type-file/");
WebElement element = driver.findElement(By.xpath("//*[@id='fileupload']"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("arguments[0].scrollIntoView()", element);
element.sendKeys("C:/Users/Mutturaj/Downloads/chromedriver_win32/chromedriver.exe");
System.out.println("File Uploaded");
// activeElement() method clicks the modal dialog
driver.switchTo().activeElement();
// Click on the button, here in out case we click on the 'Don't allow'
// button
driver.findElement(By.linkText("Don't Allow")).click();
driver.findElement(By.xpath("//input[@type='submit' and @value='submit']")).click();
System.out.println("Submitted");
}
}
Labels:
automation,
automation testing,
selenium,
testing,
web driver
Subscribe to:
Posts (Atom)