Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在smartgwt页面中找到带有selenium webdriver的简单元素_Javascript_Html_Selenium_Webdriver_Smartgwt - Fatal编程技术网

Javascript 在smartgwt页面中找到带有selenium webdriver的简单元素

Javascript 在smartgwt页面中找到带有selenium webdriver的简单元素,javascript,html,selenium,webdriver,smartgwt,Javascript,Html,Selenium,Webdriver,Smartgwt,我正在使用SeleniumWebDriver测试smartgwt应用程序。 这对于smartgwt小部件非常有效,如下所示: JavascriptExecutor executor = (JavascriptExecutor) context; return (WebElement) executor.executeScript("return AutoTest.getElement(arguments[0]);", location); 在上述情况下,位置类似于//IButton[id=i

我正在使用SeleniumWebDriver测试smartgwt应用程序。 这对于smartgwt小部件非常有效,如下所示:

JavascriptExecutor executor = (JavascriptExecutor) context;

return (WebElement) executor.executeScript("return AutoTest.getElement(arguments[0]);", location);
在上述情况下,位置类似于
//IButton[id=isc\u按钮]/

但是,我们的页面上也有一些“基本”html元素,它们不是smartgwt小部件,但它们确实有一个id。因此,我尝试如下操作(因为上面的操作不适用于这些元素):

但这不起作用。即使使用firebug,我也尝试了
document.getElementById('xxx')
查找一个元素,我知道该元素存在于给定的ID中(我可以通过firebug的html选项卡上的检查器找到它),但这也不起作用

有人知道为什么,以及如何在生成的DOM树中通过javascript访问一个简单的html元素吗


谢谢

“不起作用”就像“什么也没回来”一样?页面上是否有
iframe
元素?使用
context.findElement(By.id('thatId'))时,可以
WebDriver
查找这些元素?您是否可以控制元素的创建方式?通常,通过直接写入创建元素时,找不到该元素。'this.eventFiringWebDriver.findelelement(by.id(location))'s提供
NoTouchElementException
。顺便说一句,该页面确实包含iframe,但我的elment不在iframe中。您尝试过吗?如果不是这样的话,也许可以挽救这一天。如果是,那么除了
innerHTML
理论,我不知道-如果您通过该属性创建元素,那么无论如何都找不到它。如果找不到字段,我们总是在几秒钟后再试两次,所以一定是您提到的
innerHTML
。即使在firebug中,
getElementById()
也无法工作,这也让我感到困扰。。。
JavascriptExecutor executor = (JavascriptExecutor) context;
executor.executeScript("return document.getElementById(arguments[0]);", location);