Tag: selenium

即使我在正确的域上,Selenium addCookie也会获得无效的Cookie域exception

所以我试图用Selenium / Geb将以前保存的cookie加载到我的网络驱动程序中。 首先,我转到域名,然后尝试添加cookie。 但cookie域和url域不相互注册: Caught: org.openqa.selenium.InvalidCookieDomainException: You may only add cookies that would be visible to the current domain: .domain=.example.com => .www.example.com Build info: version: ‘2.35.0’, revision: ‘8df0c6bedf70ff9f22c647788f9fe9c8d22210e2’, time: ‘2013-0 8-17 12:46:41’ System info: os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘3.2.0-48-generic’, java.version: ‘1.6.0_27’ Driver info: driver.version: unknown 似乎cookie的域名是.example.com ,当我访问http://example.com时,我所访问的域名是.www.example.com 。 我能想到的唯一解决方案是覆盖一些方法来欺骗我当前的域名,但我不知道如何去做。

如何确定浏览器关闭的时间?

我使用Selenium Webdriver自动化网站(填写表单并点击)以节省用户的时间。 我遇到了一个恼人的问题: Selenium似乎不支持浏览器本身的任何事件监听器。 当浏览器关闭时, 不会调用 driver.quit()并且会出现一个不可用的驱动程序,它会抛出各种exception。 无法知道浏览器何时关闭,我无法创建新的驱动程序实例。 我需要的是在浏览器关闭时通知我的程序的一些方法。 用户可能会因为破坏我程序的任何原因而关闭浏览器。 如果不重新启动应用程序,用户将无法再次运行自动化任务。 知道浏览器何时关闭将允许我调用driver.quit()并在用户想要再次运行时创建一个新的驱动程序实例。 当浏览器死亡时,抛出的错误在浏览器中并不统一,这个问题变得更加复杂。 使用Firefox,我可能会使用Chrome NullPointer和WebDriverExceptions获得UnreachableBrowserException。 为了澄清,我知道如何关闭驱动程序和浏览器,但我不知道它们何时被外部源关闭。 这可以通过跨浏览器方式在Selenium 2中完成(如果是,如何)或者我是否需要找到另一种方式(如另一个库)来观看浏览器窗口?

如何使用ChromeDriver在Chrome中执行Selenide

我开始使用selenide(selenium wrapper api)并且必须说它是一个很好的工具,但我唯一的问题是它缺乏在线文档或用法示例。 知道如何在google-Chrome中运行以selenide编码的应用程序。 我使用eclipse作为IDE。 我在运行配置中添加了一个带有值chrome的环境变量“browser”但是当我运行它时会选择firefox。 我的堆栈是JDBC Java Selenide

如何从我的Java应用程序中设置Selenium的代理设置?

我想从我的Java应用程序中更改selenium服务器的代理。 当我设置代理时,Selenium服务器不使用此设置的常见方式。 我的意思是当我启动selenium浏览器并进入IP检查服务(搜索谷歌搜索“我的IP是什么”)时,我希望代理IP出现而不是我的IP地址。

Selenium WebDriver – 意外的modal dialog警报

我正在尝试使用WebDriver来自动化网站。 我正在使用Firefox驱动程序,但主页有一个弹出模式警报窗口:说: 您需要使用IE 6.0查看此应用程序。 否则一些function可能无法正常工作我检查了页面的来源,它有一个function。 模态警报不是HTML元素,我尝试使用FireBug查找任何元素,但无济于事。 if ( strBrowName == “Microsoft Internet Explorer” ) { if ( (( strBrowVersion.indexOf( ‘MSIE 6’ ) ) > 0 ) ) { } else { alert( “You need to use IE 6.0 for viewing this application. Else some features may not work” ); } 在我的WebDriver代码中,我在驱动程序中使用了以下function(如此处的其他post所示) DesiredCapabilities dc=new DesiredCapabilities(); dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.ACCEPT); […]

如何按特定顺序运行maven测试?

我有一个maven项目和几个测试类。 我希望使用插件surefire以特定顺序运行这些测试。 例如,我有: ClassTest1.java ClassTest2.java ClassTest3.java ClassTest4.java 我想运行Class 1,然后是2,然后是3,最后是4。 如何在pom.xml中指定它?

使用Java中的Selenium快速获取每个WebElement的class属性

我希望用selenium快速获取页面上每个WebElement的class属性。 目前,我正在做以下事情: allElements = new ArrayList(m_webDriver.findElements(By.cssSelector(“*”))); for (WebElement element : allElements) { String className = element.getAttribute(“class”); } 这个过程非常慢,在包含500个元素的页面上花费超过30秒。 我尝试并行化getAttribute调用,这是该方法中最慢的部分,但没有速度增加。 这让我相信每次调用getAttribute都是获取信息而不是在本地存储信息。 有没有更快或可并行的方式来做到这一点?

执行多个黄瓜function文件

当我提交单个特征文件时,它可以完美地工作。 我想将具有多个function文件的function文件夹路径传递给runner脚本。 任何人都可以帮助执行多个function文件? 所有function文件都具有相同的步骤,但数据不同,文件名不同。 @RunWith(Cucumber.class) @CucumberOptions(format = {“pretty”}, features = “C:\\TESTER\\Execution\\uidata\\featurefiles\\”, glue={“com.test.auto.stepdefs”},dryRun=false) public class CucumberTest { } 我感谢你的帮助。

Selenium没有在IE中检测到第二个窗口

我的应用程序打开了一个单击按钮的新窗口,我需要在该窗口中执行一些操作。 但是selenium webdriver的响应getWindowHandles()方法只有一个窗口id。 如果在打开新窗口后调用getWindowHandles()有延迟,则会发生这种情况。 selenium存在已知问题。 https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration 但即使是解决方案也不适用于我。 代码如下 DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); RemoteWebDriver driver = new RemoteWebDriver(new URL(“http://localhost:4444/wd/hub”), capabilities); driver.get(“https://”); WebElement userName = driver.findElement(By.name(“usr_name”)); userName.sendKeys(“ABCD”); WebElement password = driver.findElement(By.name(“usr_password”)); password.sendKeys(“password”); WebElement login = driver.findElement(By.name(“OK”)); login.click(); WebElement popup= driver.findElement(By.name(“popup”)); popup.click(); Thread.sleep(1000); Set windowHandles = driver.getWindowHandles(); System.out.println(windowHandles); Set“ windowHandles ”将只返回一个窗口: “[fcdad457-9090-4dfd-8da1-acb9d6f73f74]” 但如果我取消睡眠。 它将返回两个窗口ID: [90cc6006-0679-450c-a5b3-6602bcb41a16, 7211bbfd-2616-4460-97e7-56c0e632c3bb] 我无法移除睡眠,因为这只是一个示例程序,在实际应用程序中,它们之间会有一些延迟。 请让我知道你的想法。 […]

java.lang.NoSuchMethodError:com.google.common.io.Closeables.closeQuietly(Ljava / io / Closeable;)V

我是selenium的新手。我在使用Selenium WebDriver时遇到了一些问题。 我想用Selenium WebDriver打开网站,比如www.filpkart.com 我的代码 package com.screen; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class HTMLParseExample { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); //Launch website driver.get(“http://www.flipkart.com”); driver.close(); } } 我正面临下面提到的这个错误。 Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.io.Closeables.closeQuietly(Ljava/io/Closeable;)V at org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:60) at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:504) at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:482) at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:76) at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:142) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:80) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:121) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:77) […]