org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令的持续时间或超时可以互动: [英] org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout:

查看:4975
本文介绍了org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令的持续时间或超时可以互动:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是给硒异常如此可见元素。当我把建立在我的机器的作品,我不明白这一点,因为! (测试建立在竹)

这是一个例外:

\r
\r

org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能不可以用命令的持续时间或超时互动:30.06秒生成信息:版本:2.44.0,修订版:'76d78cf323ce037c5f92db6c1bba601c2ac43ad8,时间:2014年10月23日13点11分四十秒系统信息:主机:'N / A ',IP:'N / A',os.name:'Linux的,os.arch:AMD64,os.version:3.2.0-52虚',java.version:1.7.0_72会议ID:1757208d-d49e-4792-B053-e55e7300c233驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver能力[{=平台LINUX,acceptSslCerts = TRUE,javascriptEnabled = TRUE,cssSelectorsEnabled = TRUE,databaseEnabled = TRUE,browserName =火狐, handlesAlerts = TRUE,nativeEvents =假,webStorageEnabled = TRUE,旋转=假,locationContextEnabled = TRUE,applicationCacheEnabled = TRUE,takesScreenshot = TRUE,版本= 34.0}]\r
org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此,任何人不得互动\r
命令持续时间或超时:30.06秒

\r

\r
\r

code:

 字符串名称;
字符串键;@之前
公共无效设置()抛出InterruptedException的{    。driver.findElement(By.id(menu_topMenu.maintenance))点击();
    视频下载(1000);
    。driver.findElement(By.id(menu_topMenu.route))点击();
}@测试
公共无效测试()抛出InterruptedException的{    AddRoute addRoute =新AddRoute(驾驶员);
    addRoute.add();
    名称= addRoute.getName();
    键= addRoute.getKey();
    视频下载(3000);
    driver.findElement(By.cssSelector
            (#Route_btn_novo))点击()。
    driver.findElement(By.cssSelector
            (#Route_key>输入[类型= \\文本\\]))的SendKeys(密钥);
    driver.findElement(By.cssSelector
            (#Route_description>输入[类型= \\文本\\]))清()。
    driver.findElement(By.cssSelector
            (#Route_description>输入[类型= \\文本\\])。)的SendKeys(名);
    driver.findElement(By.cssSelector
            (#Route_organization> div.lookUpHitArea)。)点击();
    driver.findElement(By.cssSelector
            (#MonetUIFieldsLookupGridContainer_organization> div.slick-pane.slick窗格-top.slick窗格左> div.slick-viewport.slick视口-top.slick视口左> DIV> DIV:第n柴尔德(2)方式> div.slick-cell.l0.r0.cell排))点击();
    driver.findElement(By.cssSelector
            (#Route_plannedCost>输入))的SendKeys(10000)。
    driver.findElement(By.cssSelector
            (#Route_origin> div.lookUpHitArea)。)点击();
    driver.findElement(By.cssSelector
            (#MonetUIFieldsLookupGridContainer_location> div.slick-pane.slick窗格-top.slick窗格左> div.slick-viewport.slick视口-top.slick视口左> DIV> DIV:第n柴尔德(1)方式> div.slick-cell.l1.r1.cell-row.selected))点击();
    driver.findElement(By.cssSelector
            (#Route_lastStopIsDestination>输入)。)点击();
    视频下载(1000);
    driver.findElement(By.cssSelector
            (#Route_btn_save_and_close))点击()。
    视频下载(3000);
    assertTrue(罗塔existente NAO validada corretamente
            isDisplayedByCssSelector(驱动程序,#form_and_grid> DIV> div.monetInlineAlerContainer>的div));
}

}

我不知道更多的事情要做什么!


解决方案

我不知道你的整个设置看起来怎么样。但是,常见的做法是使用硒网格的在这种情况下。这个想法是有硒枢纽和多个从机(多达你需要和可能的虚拟机),并有CI服务器控制执行测试的奴隶。您遇到的问题是因为CI服务器不会表现得像你的本地计算机在做什么。该元素是不可见的手段硒不能与浏览器进行交互,它不应该在CI。见<一href=\"http://grid.selenium.google$c$c.com/git-history/22ed3ff910401af083bf06a4d13514f4c6a623ca/src/main/webapp/how_it_works.html\"相对=nofollow>这个来探索更多关于格。 应该可以帮助您开始。

注:这是很多方法可以从CI

执行硒测试之一

My problem is that selenium give the exception so visible elements. I don't understand this because when I put to build in my machine works! ( The tests build at bamboo).

This is a exception:

org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 30.06 seconds Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40' System info: host: 'N/A', ip: 'N/A', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-52-virtual', java.version: '1.7.0_72' Session ID: 1757208d-d49e-4792-b053-e55e7300c233 Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=34.0}]
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 30.06 seconds

Code:

String name;
String key;

@Before
public void setUp() throws InterruptedException {

    driver.findElement(By.id("menu_topMenu.maintenance")).click();
    Thread.sleep(1000);
    driver.findElement(By.id("menu_topMenu.route")).click();
}

@Test
public void test() throws InterruptedException {

    AddRoute addRoute = new AddRoute(driver);
    addRoute.add();
    name = addRoute.getName();
    key = addRoute.getKey();
    Thread.sleep(3000);
    driver.findElement(By.cssSelector
            ("#Route_btn_novo")).click();
    driver.findElement(By.cssSelector
            ("#Route_key > input[type=\"text\"]")).sendKeys(key);
    driver.findElement(By.cssSelector
            ("#Route_description > input[type=\"text\"]")).clear();
    driver.findElement(By.cssSelector
            ("#Route_description > input[type=\"text\"]")).sendKeys(name);
    driver.findElement(By.cssSelector
            ("#Route_organization > div.lookUpHitArea")).click();
    driver.findElement(By.cssSelector
            ("#MonetUIFieldsLookupGridContainer_organization > div.slick-pane.slick-pane-top.slick-pane-left > div.slick-viewport.slick-viewport-top.slick-viewport-left > div > div:nth-child(2) > div.slick-cell.l0.r0.cell-row")).click();
    driver.findElement(By.cssSelector
            ("#Route_plannedCost > input")).sendKeys("10000");
    driver.findElement(By.cssSelector
            ("#Route_origin > div.lookUpHitArea")).click();
    driver.findElement(By.cssSelector
            ("#MonetUIFieldsLookupGridContainer_location > div.slick-pane.slick-pane-top.slick-pane-left > div.slick-viewport.slick-viewport-top.slick-viewport-left > div > div:nth-child(1) > div.slick-cell.l1.r1.cell-row.selected")).click();
    driver.findElement(By.cssSelector
            ("#Route_lastStopIsDestination > input")).click();
    Thread.sleep(1000);
    driver.findElement(By.cssSelector
            ("#Route_btn_save_and_close")).click();
    Thread.sleep(3000);
    assertTrue("Rota existente nao validada corretamente",
            isDisplayedByCssSelector(driver, "#form_and_grid > div > div.monetInlineAlerContainer > div"));
}

}

I don't know more what to do!

解决方案

I am not sure how your entire set up looks like. But, a common practice is to use Selenium Grid in such case. The idea is to have a selenium hub and multiple slaves(as many as you need and may be virtual machines) and have the CI server controlling the slaves to execute the tests. The issue you are having is because of CI server is not acting like your local machine is doing. The element is not visible means selenium is not able to interact with the browser which it should not on CI. See this to explore more about the grid. This should help you to get started.

Note: This is one of many ways to execute selenium tests from CI

这篇关于org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令的持续时间或超时可以互动:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆