Tag: selenium firefoxdriver

通过selenium在firefox中打开私有模式

其实我想通过selenium打开一个隐身/私有模式的firefox浏览器,但每次我试过它都是在正常模式下打开firefox。 经过一些谷歌搜索我得到了这个代码,我曾经通过selenium在firefox中打开私有模式,但它无法正常工作。 FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(“browser.privatebrowsing.autostart”, true); WebDriver driver = new FirefoxDriver(firefoxProfile); driver.get(“http://www.google.com”); 有人可以帮忙怎么做?

Selenium moveByOffset不做任何事情

我在Linux Xubuntu 13.10上使用Firefox 28.0运行最新的selenium 2.41 我正试图让FirefoxDriver将鼠标移到页面上(在我的测试中,我使用了有线网页,它有很多hover激活的菜单),但是moveByOffset没有做任何明显的鼠标,在所有: package org.openqa.mytest; import java.util.List; import java.io.File; import java.lang.*; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.*; import org.openqa.selenium.firefox.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.*; import org.apache.commons.io.FileUtils; public class Example { public static void main(String[] args) throws Exception { // The Firefox driver supports javascript FirefoxProfile profile = new FirefoxProfile(); […]

通过xpath Selenium java选择动态生成的ID的Web元素

我需要在下拉窗口中选择一个元素。 每当我打开我正在测试的网站的下拉窗口时,网站会随机为该下拉窗口生成一个ID。 下拉窗口的先前实例是可见的(使用Firebug)但不可选。 有一个静态路径,但只有在我使用ChromeDriver测试它时才有效,而不是在我使用FirefoxDriver时。 通过类名定位动态生成的元素(下拉窗口的每个实例具有相同的类)在我第一次尝试时起作用,但每次使用ChromeDriver和FirefoxDriver后我都会收到错误。 我认为它可能试图找到第一个实例,但不是可选择的实例。 这是我的动态代码: driver.findElement(By.xpath(“//div[@class=’really long name for drop down menu’]/ul/li[2]”)).click(); 这是我的静态代码: driver.findElement(By.xpath(“//option[normalize-space(.)=’Text’]”)).click(); 这是动态HTML: Text 这是静态HTML: Select a Thing: Text

Selenium FireFoxDriver在加载firefox后更改配置文件?

ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffprofile = profile.getProfile(“default”);//using firefox default profile ffprofile.setPreference(“permissions.default.image”, 2); // this make ff to block web page images WebDriver ff = new FirefoxDriver(ffprofile); // executing firefox with specified profile ff.navigate().to(“www.google.com”); // loading web page //codes for changing image blocking ??????????? 如何在加载某些网页后更改图像阻止?

Selenium 3.0 Firefx驱动程序因org.openqa.selenium.SessionNotCreatedException而失败:无法创建新的远程会话

Selenium 3.0 Firefx驱动程序因org.openqa.selenium.SessionNotCreatedException而失败:无法创建新的远程会话。 System.setProperty(“webdriver.gecko.driver”, “…./geckodriver.exe”); capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(“marionette”, true); driver = new FirefoxDriver(capabilities); Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@23aa363a, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@23aa363a, version=, platform=ANY}], required capabilities = Capabilities [{}] Build info: version: ‘3.0.0’, revision: ‘350cf60’, time: ‘2016-10-13 10:48:57 -0700’ System info: host: ‘D202540’, ip: ‘10.22.19.193’, os.name: […]

如何使用Selenium for Firefox禁用推送通知?

我想通过Selenium Webdriver启动Firefox浏览器时禁用通知。 我找到了这个答案 ,但它已被弃用,并且在Firefox上不起作用(尽管它在Chrome上运行得很好)。 我将这个依赖项用于我的pom.xml : org.seleniumhq.selenium selenium-java 3.11.0

如何使用Selenium Webdriver下载excel时在firefox中处理下载弹出窗口

我试图从Firefox和Webdriver下载Excel文件,但我无法处理下载弹出窗口。 单击按钮时,我需要自动下载文件,而不显示弹出窗口。 这是我的代码: FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(“browser.download.folderList”, 2); firefoxProfile.setPreference(“browser.download.manager.showWhenStarting”, false); firefoxProfile.setPreference(“browser.download.dir”, Constant.Downloaded_Path); firefoxProfile.setPreference(“browser.helperApps.neverAsk.saveToDisk”, “text/csv/xls/xlsx”); firefoxProfile.setPreference(“browser.helperApps.neverAsk.openFile”, “text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml”); firefoxProfile.setPreference(“browser.helperApps.alwaysAsk.force”, false); firefoxProfile.setPreference(“browser.download.manager.alertOnEXEOpen”, false); firefoxProfile.setPreference(“browser.download.manager.focusWhenStarting”, false); firefoxProfile.setPreference(“browser.download.manager.useWindow”, false); firefoxProfile.setPreference(“browser.download.manager.showAlertOnComplete”, false); firefoxProfile.setPreference(“browser.download.manager.closeWhenDone”, false); return firefoxProfile; 但是,上面的代码不起作用。 任何人都可以帮忙吗?