Selenium没有访问打印对话框,单击“确定”按钮,如何切换到打印对话框并单击确定按钮,

时间:2017-01-02 06:01:42

标签: java selenium selenium-webdriver

以下代码无效,请帮我保存PDF。我需要将pdf保存在某个位置。

请帮我解决这个问题。     公共类amazonpacking扩展了Dictionary {

static WebDriver driver;

@BeforeTest
public static void before() {

    System.setProperty("webdriver.firefox.marionette",
            "C:\\selenium\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get(AmazonURL);
}

@Test(priority = 0)
public void Amazon() throws InterruptedException {

    driver.findElement(By.id("ap_email")).sendKeys("mandkanw@gmail.com");
    driver.findElement(By.id("ap_password")).sendKeys("*****");

    Thread.sleep(1000);

    driver.findElement(By.id("signInSubmit")).click();
    Alert alert = driver.switchTo().alert();
    alert.accept();

    Robot robot = null;
    try {
        robot = new Robot();
    } catch (AWTException e) {
        e.printStackTrace();
    }
    robot.delay(5000);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    robot.keyPress(KeyEvent.VK_ESCAPE);
    robot.keyRelease(KeyEvent.VK_ESCAPE);

}

}

0 个答案:

没有答案