- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Selenium 2.2。
我试图点击最初没有显示但变得可见的元素
在测试过程中。起初有时 webdriver 似乎工作得太快,所以元素不可见,导致 ElementNotVisibleExceptions。我添加了 WebDriverWait 以等待这些元素变为可见/可点击。但是现在我在使用时遇到了这个随机错误
WebDriverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id")));
WebDriverWait.until(ExpectedConditions.elementToBeClickable(By.id("id")));
org.openqa.selenium.WebDriverException: Error determining if element is displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 219 milliseconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:59'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1 build 2600 Service Pack 3', java.version: '1.6.0'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:170)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:123)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:438)
at org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:280)
at org.openqa.selenium.support.ui.ExpectedConditions.elementIfVisible(ExpectedConditions.java:136)
at org.openqa.selenium.support.ui.ExpectedConditions.access$1(ExpectedConditions.java:135)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:106)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.ExpectedConditions$11.apply(ExpectedConditions.java:252)
at org.openqa.selenium.support.ui.ExpectedConditions$11.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:201)
at MyTest.myTest(MyTest.java:xx)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
最佳答案
确保页面只有一个 modalPanel。尝试获取可见面板(java):
public WebElement getVisibleModalPanel(){
for (WebElement element : driver.findElements(By.cssSelector('csslocator'))) {
if (element.isDisplayed()) {
return element;
}
}
return null;
}
(new WebDriverWait(getDriver(), timeout, 400)).ignoring(StaleElementReferenceException.class).until(
new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
for (WebElement element : driver.findElements(By.cssSelector(locator))) {
if (element.isDisplayed()) {
return true;
}
}
return false;
}
});
关于 Selenium 网络驱动程序 : Random Error determining if element is visible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12603972/
我制作了一个 DIV 和 visibility: hidden 并附加了一个 ::before 这个 DIV 的伪元素 visibility : 可见。这在 Firefox、Chrome 和 Safa
我正在使用 jquery 可见选择器来检查子元素是否可见。但令人惊讶的是 .is("visible") 和 .is(":visible") 在使用 css Visibility:hidden 时显示不
我有这个代码 #checkboxDIV { visibility: hidden; } #itemcard:hover #checkboxDIV {
我有一个用 ul 创建的菜单/li列出。 为了创造一个不错的效果,我有以下 css: #menu ul { /* ... */ visibility:hidden; /* ..
我想要的是,当我点击 Dashboard Button 时,它会像 SlidingDrawer 一样打开,打开后再次点击它会关闭。我使用这个自定义抽屉是因为 SlidingDrawer 已弃用。 现在
如何使用 jQuery 只选择可见元素? jQuery 选择器 :visible 和 :hidden 只尊重 display:none 作为真的隐藏?不是可见性:隐藏或可见性:可见。 我知道它们在技术
为什么我的 $('#myDiv').css('visibility', 'visible'); 不起作用? $('#clickdiv').click(function() { alert($(
在 $(document).ready 函数中通过 JavaScript 将子容器设置为 visibility: visible 时,我遇到了一个奇怪的问题。 问题是: 我有一个父元素,它有 boot
在 jQuery 中: e.is(':visible'); 检查元素是否显示。 jQuery 中是否有一个函数可以检查元素是否具有隐藏或可见属性可见性? 现在我必须自己实现这个功能。但我想使用 jQu
我在 mvc 中使用一个帖子表单,在帖子中我想显示一个隐藏的 div(惊喜)。 我正在使用 js/jquery 来显示 div,它可以在所有浏览器中工作,除了 mac 上的 safari :( 我现在
我似乎无法获得我的 jquery {{NotificationNavDot}} 功能正常工作! 在下面找到帮助文件: {{NotificationNavDot}} 在下面找到我的帮助
WPF 中的 Visibility.Collapsed 和 Visibility.Hidden 有什么区别? 最佳答案 不同之处在于,Visibility.Hidden隐藏了控件,但保留了它在布局中占
我有一个 if 语句来检查我的 div 下面是否没有任何可见内容,如果是,我会隐藏子元素的同级元素。 var $remainingprojects = $searchproject.s
这是我的菜单模型 HTML Menu 1 (overflow:hidden) Item 1 submenu 1 submen
编辑 3 实际上,我根本不需要弄乱可见性/不透明度...所以我删除了那些行(如编辑 2 所示)...添加了动画 -播放状态:暂停/运行.... 得到了我想要的效果... 编辑 2:感谢 Gineto
在我的应用程序中有一个广告 WebView ,它在 Activity 开始时调用一个 url。一切都很好,除了一件小事,它更像是一个可见性问题......所以问题是,当我开始 Activity 时,我
根据 the "visible" binding documentation , 如果 visible 的值为 false,Knockout 使用 display: none 隐藏元素。我怎样才能让它
* { margin: 0; padding: 0; border: 0; } .navBar { background-color: #2A2A2A; min-width: 10
android 布局使用 layout_weight。我的目标是所有组件的 1/3,但有时页脚实际上设置为消失,然后可见。从 gone 设置为 visible 时,权重计算如何工作?我没有看到具有 1
我有两个单选按钮,两个文本框和一个按钮。 当我点击第一个按钮时,应该只会出现一个文本框,当我点击第二个按钮时,应该会出现两个文本框。 但我想使用 visibility:hidden|visible 属
我是一名优秀的程序员,十分优秀!