无法点击使用Selenium WebDriver

时间:2016-09-08 08:35:40

标签: java selenium selenium-webdriver webdriver qooxdoo

HTML CODE

</div>
<div class="qx-outSet" qxselectable="off" style="overflow:...>
<div class="qx-button" tabindex="4" qxselectable="off" style="overflow:...>

******************************************** I have to click on bellow OK button ****************************
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; box-sizing: border-box; position: absolute; cursor: default; -moz-user-select: none; color: rgb(26, 26, 26); font-family: Arial,"Liberation Sans",sans-serif; font-size: 14px; left: 24px; top: 3px; width: 21px; height: 16px;" qxselectable="off" qxanonymous="true">OK</div>
</div>**
<div class="qx-button" tabindex="5" qxselectable="off" style="overflow: hidden; box-sizing: border-box; position: absolute; outline: medium none; -moz-user-select: none; cursor: default; padding: 3px 9px; left: 88px; top: 9px; width: 70px; height: 24px;">
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; box-sizing: border-box; position: absolute; cursor: default; -moz-user-select: none; color: rgb(26, 26, 26); font-family: Arial,"Liberation Sans",sans-serif; font-size: 14px; left: 12px; top: 3px; width: 45px; height: 16px;" qxselectable="off" qxanonymous="true">Cancel</div>
</div>

现在我正在使用带有TestNG的selenium Web Driver在Qooxdoo框架工作(它的javaScript框架)中自动化Web应用程序。
在这里我已经实现了一些东西但是有些弹出窗口是使用嵌套的<div>制作的,而selenium popup处理程序无法处理它。 通过使用动作类,我可以在文本区域{通过下面提到的selenium代码}中写入,弹出显示(找到附件)但我不能单击按钮(OK,CANCEL)。

// wd is WebDriver Object 
WebElement element = wd.findElement(By.className("qx-window")); // qx-window is class name of div in which text area is  present
Actions actions = new Actions(wd);
actions.moveToElement(element).click().perform();
Thread.sleep(5000);
// write text in text area 
wd.findElement(By.tagName("textarea")).sendKeys("TEST");

wd.findElement(By.xpath(".//*[@id='demindoRoot']/div[4]/div[2]/div[2]/div[1]")).click();  //  CODE TO CLICK ON "OK" BUTTON 

我试图通过再次使用动作类来切换焦点到存在按钮的div但是我也不能。

错误日志:

org.openqa.selenium.NoSuchElementException:无法找到元素:{“method”:“xpath”,“selector”:“....

1 个答案:

答案 0 :(得分:1)

尝试以下代码,如有任何例外情况,请与我们联系:

TypeError: res.sendFile is not a function
    at /home/ubuntu/workspace/server.js:18:9
    at callbacks (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:161:37)
    at param (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:135:11)
    at pass (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:142:5)
    at Router._dispatch (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:170:5)
    at Object.router (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:33:10)
    at next (/home/ubuntu/workspace/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at resume (/home/ubuntu/workspace/node_modules/express/node_modules/connect/lib/middleware/static.js:60:7)
    at SendStream.error (/home/ubuntu/workspace/node_modules/express/node_modules/connect/lib/middleware/static.js:73:37)
    at emitOne (events.js:77:13)
    at SendStream.emit (events.js:169:7)
    at SendStream.error (/home/ubuntu/workspace/node_modules/express/node_modules/connect/node_modules/send/lib/send.js:147:51)
    at SendStream.onStatError (/home/ubuntu/workspace/node_modules/express/node_modules/connect/node_modules/send/lib/send.js:248:48)
    at /home/ubuntu/workspace/node_modules/express/node_modules/connect/node_modules/send/lib/send.js:320:26
    at FSReqWrap.oncomplete (fs.js:82:15)
TypeError: res.sendFile is not a function
    at /home/ubuntu/workspace/server.js:18:9
    at callbacks (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:161:37)
    at param (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:135:11)
    at pass (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:142:5)
    at Router._dispatch (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:170:5)
    at Object.router (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:33:10)
    at next (/home/ubuntu/workspace/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at resume (/home/ubuntu/workspace/node_modules/express/node_modules/connect/lib/middleware/static.js:60:7)
    at SendStream.error (/home/ubuntu/workspace/node_modules/express/node_modules/connect/lib/middleware/static.js:73:37)
    at emitOne (events.js:77:13)
    at SendStream.emit (events.js:169:7)
    at SendStream.error (/home/ubuntu/workspace/node_modules/express/node_modules/connect/node_modules/send/lib/send.js:147:51)
    at SendStream.onStatError (/home/ubuntu/workspace/node_modules/express/node_modules/connect/node_modules/send/lib/send.js:248:48)
    at /home/ubuntu/workspace/node_modules/express/node_modules/connect/node_modules/send/lib/send.js:320:26
    at FSReqWrap.oncomplete (fs.js:82:15)