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");
}
}
Friday, March 8, 2019
Dealing with modal dialog in selenium Webdriver
Labels:
automation,
automation testing,
selenium,
testing,
web driver
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment