3
我无法解除Firefox位置提醒。当我点击商店定位器时,Firefox将打开位置警报。我想点击“不允许”。我知道如何处理硒web驱动程序中的警报框。但是,我无法点击提醒。如何在selenium webdirver中关闭Firefox的“共享位置”提醒
package toysrus;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.UnexpectedAlertBehaviour;
import org.openqa.selenium.UnhandledAlertException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
public class Toysrus {
public WebDriver driver;
@Test(priority=1)
public void firefox() throws InterruptedException
{
System.setProperty("webdriver.gecko.driver","C:/Users/naveenkumar.d/Downloads/geckodriver-v0.17.0-win64/geckodriver.exe");
driver=new FirefoxDriver();
}
@Test(priority=2)
public void urlaccess()
{
String URL="http://m.toysrus.com/?TRU=1";
driver.get(URL);
}
@Test(priority=3)
public void menucontainner()
{
driver.findElement(By.id("sk_menu_icon_container")).click();
}
@Test(priority=3)
public void storeloocator() throws InterruptedException
{
driver.findElement(By.name("storelocator")).click();
Thread.sleep(5000);
Alert alert = driver.switchTo().alert();
alert.dismiss();
}
您是否尝试过这个 - 1.点击取消按钮 '''driver.switchTo() .alert()。dismiss();''' 2.点击警报的'OK'按钮。 '''driver.switchTo()。alert()。accept();''' –
否它不工作。我已经试过了 –