Tag: firefox

无法使用IEDriver单击IE上的链接

我正在使用的代码如下所示。 多浏览器 package com; import java.io.File; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; import org.testng.annotations.Test; public class MultiBrowser { public WebDriver driver; // Passing Browser parameter from TestNG xml @Parameters(“browser”) @BeforeClass public void beforeTest(String browser) { // If the browser is Firefox, then do this if(browser.equalsIgnoreCase(“firefox”)) […]

Firefox selenium webdriver提供“不安全连接”

我用Selenium Webdriver(java)创建了一个包含20个测试的Maven项目。 现在,当我想执行我的Maven项目时,有时会出现以下错误: Mozilla错误 这是因为每次测试都要登录。 因此,当我想运行20个测试时,有时会出现错误而我无法继续测试,因此它会在Selenium Webdriver中返回“Failed test”。 有人知道如何解决这个问题吗? 我试过把“Thread.sleep(30000);” 在每次测试结束时给他们一些时间“不要看起来像机器人”,但它不起作用…… 非常感谢你的帮助!

用于保存文件的Selenium firefox配置文件

可能重复: 访问Firefox中的文件下载对话框 我正在使用selenium和firefox从互联网上下载文件。 当我试图下载文件时,我收到下载框,询问我是否要保存文件或“打开”。 我想保存文件但不自动(想要重命名文件名),我希望浏览器会问我在哪里保存文件。 在firefox设置中选择“总是询问保存文件的位置”选项仍然是..当我使用selenium运行脚本时,它不会询问我并保存文件。 如何设置firefox配置文件来执行此操作? 我在哪里可以看到所有firefox配置文件? 谢谢你的帮助。

使用selenium的java出错:预期

我不明白为什么我得到错误Expected [object Undefined] undefined为一个字符串 这是脚本java LoginToGmail.java WebDriver driver; driver =new FirefoxDriver(); driver.manage().window().maximize(); driver.navigate().to(“http://www.facebook.com”); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebElement act= driver.findElement(By.id(“email”)); act.sendKeys(“rupali9392@gmail.com”); 完整堆栈错误是: org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string Build info: version: ‘unknown’, revision: ‘5234b32’, time: ‘2017-03-10 09:00:17 -0800’ Capabilities [{moz:profile=C:\Users\SHEKHAR\AppData\Local\Temp\rust_mozpr‌​ofile.mipot0y6Nzs5, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal ,platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=6.1, moz:processID=5892, browserName=firefox, platformName=windows_nt}]

在selenium中绕过capcha

我登录网站时有很多自动化测试运行我是unit testing,但我不能(没有权限)从登录页面中删除capcha。 有没有办法使用selenium 2.0这样我可以启动WebDriver实例,比如firefox,然后手工执行capcha然后让WebDriver(我使用服务器的java jar)从那里“接管”? 谢谢!

如何使用Selenium webdriver和Java为firefox设置代理?

System.setProperty(“webdriver.gecko.driver”, “E:\\geckodriver-v0.18.0-win64\\geckodriver.exe”); Proxy p = new Proxy(); p.setSocksProxy(“83.209.94.87:35923”); DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(CapabilityType.PROXY, p); WebDriver driver = new FirefoxDriver(cap); driver.get(“https://www.google.com.au”); 此代码位于main方法内。 当我运行此代码时,启动了Firefox,但未遵循google url,并且代理未设置为我在上面的代码中指定的代理。 我怎样才能解决这个问题? public static void main(String[] args) throws InterruptedException, IOException, UnsupportedEncodingException { while (true) { System.setProperty(“webdriver.gecko.driver”, “E:\\geckodriver-v0.18.0-win64\\geckodriver.exe”); WebDriver driver; String PROXY = “83.209.94.87:35923”; //Bellow given syntaxes will set browser proxy settings using […]

如何让Firefox在Mac OSX上使用Selenium WebDriver

我正在尝试为WebDriver配置代理设置,所以我使用了以下代码…. FirefoxProfile profile = new FirefoxProfile(); profile.setPreference(“network.proxy.type”, 1); profile.setPreference(“network.proxy.http”,”207.229.122.162″); profile.setPreference(“network.proxy.http_port”, 3128); WebDriver driver = new FirefoxDriver(profile); selenium = new WebDriverBackedSelenium(driver, “http://www.example.com/”); 并且在对文件执行运行后,我得到例外… org.openqa.selenium.WebDriverException:在PATH中找不到firefox二进制文件。 确保安装了firefox。 操作系统似乎是:MAC 系统信息:os.name:’Mac OS X’,os.arch:’x86_64’,os.version:’10 .6.8’, java.version:’1.6.0_29′ 驱动程序信息:driver.version:FirefoxDriver 任何人都可以帮我解决如何以及在哪里给firefoxprofile()路径

Selenium / Firefox:命令“.click()”不适用于找到的元素

我试图找到解决这个问题的方法,我花了很多时间,但这对我来说几乎是不可能的。 问题:我在Firefox中使用Selenium和Java。 我需要找到一个元素(列表框)并单击它。 因此,代码找到元素,但单击操作不起作用。 它每次都适用于谷歌浏览器,有时只在Firefox中(有时相同的Java代码有效,有时则无效)。 当程序进入页面时,有一部分代码带有元素: SELECCIONA TALLA Guía de tallas 并且在单击元素时,代码的一部分会发生变化: 我尝试了很多解决方案,有时它可以工作,但下次我运行程序时,它不再起作用。 一些解决方案 它找到元素,但不运行单击操作。 我检查了xpath和cssSelector,并且找到了这些表达式的唯一元素。 driver.findElement(By.xpath(“//div[@id=’size-btn’ and not(contains(@class,’opened’))]/span”)).click(); // Also checked with By.cssSelector(“span.selected-size”) 我虽然是因为时间,所以我试图以这种方式解决它。 WebElement we = driver.findElement(By.xpath(“//div[@id=’size-btn’ and not(contains(@class,’opened’))]/span”)); // By.cssSelector(“span.selected-size”) Thread.sleep(3000); we.click(); 最后,我有点绝望,我创建了一个新function,尝试这样做了近60次,寻找元素代码的更改,如果有任何更改,只是尝试再次单击操作。 clickAndWaitWhileElementIsNotPresent(By.xpath(“//div[@id=’size-btn’ and not(contains(@class,’opened’))]/span”),By.xpath(“//div[@class=’size-btn opened’]/span”)); // By.cssSelector(“span.selected-size”) private void clickAndWaitWhileElementIsNotPresent(By by1, By by2) throws Exception { for (int second = […]

SessionNotCreatedException:无法创建新服务:在Ubuntu上使用Selenium Grid的GeckoDriverService无法驱动Firefox

我无法使用geckodriver从Selenium驱动Firefox。 这很奇怪,因为chrome使用相同的框架驱动而没有错误! 这些是我的版本号: Firefox 54.0 (64-bit) Chrome Version 62.0.3202.94 (Official Build) (64-bit) selenium-server-standalone-3.7.1.jar client-combined-3.5.3-nodeps.jar geckodriver-v0.19.1-linux64 chromedriver_linux64 Ubuntu 16.10 我从Selenium webdriver获得的错误如下: ——————————–Error: leder@leder-VirtualBox:~/Source/SeleniumCheese/bin$ ./execute_grid.sh Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Unable to create new service: GeckoDriverService Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’ System info: host: ‘leder-VirtualBox’, ip: ‘127.0.1.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘4.8.0-59-generic’, java.version: […]

Firefox错误:使用Java启动Selenium 3.0.1驱动程序时“您的连接不安全”

我的Firefox版本是46.0.1,Selenium版本是3.0.1。 我收到错误: 您的连接不安全 执行以下代码时: @Test public void test() { ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffProfile = profile.getProfile(“newCretedProfile”); ffProfile.setAcceptUntrustedCertificates(true); ffProfile.setAssumeUntrustedCertificateIssuer(false); System.setProperty(“webdriver.gecko.driver”, “D:\\SELENUIUM\\Drivers\\geckodriver.exe”); FirefoxDriver driver = new FirefoxDriver(ffProfile); driver.get(“http://www.google.com”); driver.quit(); } 我创建了新的firefox配置文件,并按照此URL的步骤操作 然而,当我启动任何网站时,它不起作用并给我同样的错误。