我的问题的屏幕截图如何在mozilla和chrome浏览器使用硒webdriver?
screen shot for my questionHow can I handle Geo Location popup in mozilla and chrome browser using selenium webdriver?
package tiyotesting; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.firefox.internal.ProfilesIni; import org.openqa.selenium.support.ui.Select; public class Citydropdownlist { public static void main(String[] args) throws InterruptedException { WebDriver driver = new FirefoxDriver(); driver.get("www.google"); driver.get("ec2-35-154-164-82.ap-south-1pute.amazonaws/tiyorelease3/"); WebElement ListBox = driver.findElement(By.id("supported_city_label")); ListBox.sendKeys("Ahmedabad"); ListBox.sendKeys(Keys.ENTER); } }我创建了Firefox自定义配置文件,该配置文件也无法再使用,弹出窗口对我来说是最便宜的,所以请帮助我解决问题
I created Firefox custom profile it is also not working again the popup came it is showstopper for me, so please help me to resolve the issue
推荐答案在使用Selenium 3.x时,geckodriver v0.16.1&在Mozilla Firefox 53.x中,您可以通过在新的Firefox配置文件中设置首选项来禁用地理位置"弹出窗口,如下所示:
While working with Selenium 3.x, geckodriver v0.16.1 & Mozilla Firefox 53.x, you can disable the Geo Location popup by setting the preferences in the new Firefox profile as follows:
这是最小代码的工作集,该代码可以打开预期的URL而没有地理位置"弹出窗口.
Here is the working set of minimal code which opens the intended URL without the Geo Location popup. System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe"); FirefoxProfile geoDisabled = new FirefoxProfile(); geoDisabled.setPreference("geo.enabled", false); geoDisabled.setPreference("geo.provider.use_corelocation", false); geoDisabled.setPreference("geo.prompt.testing", false); geoDisabled.setPreference("geo.prompt.testing.allow", false); WebDriver driver=new FirefoxDriver(geoDisabled); driver.get("ec2-35-154-164-82.ap-south-1pute.amazonaws/tiyorelease3/");
更多推荐
如何使用硒webdriver在mozilla和chrome浏览器中处理“地理位置"弹出窗口?
发布评论