Tag: selenium webdriver

如何使用Java在Selenium WebDriver中的隐藏字段中键入一些文本

我正在使用WebDriver和Java进行测试自动化。 我有以下隐藏的输入字段的HTML代码: 如何在Selenium2(WebDriver)中的隐藏字段中键入内容? 我编写的代码如下: driver.findElement(By.name(“body”)).sendKeys(“test body”); 但它显示以下错误:org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令持续时间或超时交互:30.04秒 有人可以帮我在隐藏字段中写/输入一些文字吗?

org.openqa.selenium.UnhandledAlertException:意外警报打开

我正在使用Chrome驱动程序并尝试测试网页。 通常它运行正常,但有一段时间我得到例外 – org.openqa.selenium.UnhandledAlertException: unexpected alert open (Session info: chrome=38.0.2125.111) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 16 milliseconds: null Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:30’ System info: host: ‘Casper-PC’, ip: ‘10.0.0.4’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: […]

在Selenium中避免NoSuchElementException的最佳方法是什么?

我在Selenium WebDriver中使用Java编写了一些测试用例,并在网格(集线器和多个节点)上执行它们。 我注意到一些测试用例由于NoSuchElementException而失败。 什么是避免NoSuchElementException并确保始终找到元素的最佳和最强大的方法?

隐含等待Vs有什么区别 在selenium webdriver中显式等待?

请分享有关selenium webdriver的知识。 请显示实时示例。

TestNG启动期间发生内部错误

我创建了一个TestNG类(FirstTest.java),当我将测试用例作为TestNG Test运行时,我收到以下错误。 在“启动FirstTest”期间发生内部错误。 显示java.lang.NullPointerException Eclipse版本:Luna Service Release 2(4.4.2) 如果有人知道请帮忙!

使用Selenium在Chrome中拍摄整页屏幕截图

我知道以前这是不可能的,但现在有了以下更新: https://developers.google.com/web/updates/2017/04/devtools-release-notes#screenshots 这似乎可以使用chrome dev工具。 现在可以在java中使用selenium吗?

Selenium IE WebDriver仅在调试时有效

我使用的是Java Gradle,Selenium 3.8.0和IEWebDriver 3.8.0。 Chrome和Firefox工作正常,但IE抛出一​​个org.openqa.selenium.TimeoutException: Expected condition failedexception,虽然IE也可以正常工作,如果我一步一步调试我的源代码。 因此,我花了很长时间才发现这个问题,并且我注意到IE在WebDriver和源代码之间失去连接,每当webDriver.get(..) ,它看起来像这样: driver.get(url); waitForPageLoaded(driver); 因此我假设有一些时间问题,但我已经尝试处理这个: public void waitForPageLoaded(WebDriver driver) { logger.debug(“Wait until the page was loaded.”); // IE seems to fail here. new WebDriverWait(driver, SeleniumConfigurator.TIME_OUT) .until(d -> ((JavascriptExecutor)d).executeScript(“return document.readyState”) .equals(“complete”)); } 然后我注意到IE需要更多配置设置,但我不允许设置其中一些:IT限制 – >我无法更改regedit条目。 但是,为什么它在调试时工作正常? 这是我的IE设置: case IE: path = “../../../../../../resources/driver/win/IEDriverServer_32_v3-8-0.exe”; url = getClass().getResource(path); if (url == […]

如何在本地(在我的电脑上)网页上使用selenium webdriver而不是在www上找到somwhere?

我必须在我硬盘上的网页上使用selenium webdriver。 我尝试过类似的东西: selenium = new WebDriverBackedSelenium(driver, “C:\\…dispatcher.html”); 而不是正常的: selenium = new WebDriverBackedSelenium(driver, “http://www.dunnowhattodo.org”); 但它不起作用(我得到错误“未知协议:c”) 它甚至可能吗? 我有点seleniumwebdriver的新用户,所以它可能是一个愚蠢的问题,但仍然我会appriciate每一个帮助,我会得到:)

我们是否有任何通用function来检查页面是否已在Selenium中完全加载

我试图在selenium中检查网页是否已加载完成(即检查是否已加载所有控件)。 我尝试下面的代码: new WebDriverWait(firefoxDriver, pageLoadTimeout).until( webDriver -> ((JavascriptExecutor) webDriver).executeScript(“return document.readyState”).equals(“complete”)); 但即使页面加载上面的代码也不会等待。 我知道我可以检查特定元素以检查它是否可见/可点击等,但我正在寻找一些通用的解决方案

线程“main”中的exceptionjava.lang.NoClassDefFoundError:org / openqa / selenium / WebDriver

我在我的pom.xml中添加了最新的Selenium依赖项 org.seleniumhq.selenium selenium-java 3.7.1 我用我的pom.xml在目录中运行了mvn clean install,我还根据Selenium文档在我的app类中导入了正确的类 import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; 但是当我尝试运行我的main方法时,我收到以下错误 Exception in thread “main” java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver 我查看〜/ .m2 / repository文件夹,我没有看到openqa文件夹,但我看到了seleniumhq文件夹。 为什么没有maven安装openqa文件夹,为什么文档说从org.openqa导入…当我的jar存储库中永远不存在。 我很困惑,我只是希望能够在我的本地存储库中成功导入selenium Webdriver。