我正在运行grunt-protractor-runner。
protractor: 2.0.0
jasmine: 1.3
Linux Ubuntu 14.4
我在点击下一页按钮时遇到问题,并在下面收到错误。
UnknownError:未知错误:元素在点处无法点击(194, -212)(会话信息:chrome = 42.0.2311.90)(驱动程序信息:chromedriver = 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),平台= Linux的 3.13.0-49-generic x86_64)with stack trace`
UnknownError:未知错误:元素在点处无法点击(194, -212)(会话信息:chrome = 42.0.2311.90)(驱动程序信息:chromedriver = 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),平台= Linux的 3.13.0-49-generic x86_64)at new bot.Error(/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113:18) 在Object.bot.response.checkResponse (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9) 在 /home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:377:20 at [object Object] .promise.ControlFlow.runInFrame_ (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20) at [object Object] .promise.Callback_.goog.defineClass.notify (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25) at [object Object] .promise.Promise.notify_ (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12) 在Object.goog.array.forEach的Array.forEach(native)处 (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/array/array.js:203:43) at [object Object] .promise.Promise.notifyAll_ (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16) at [object Object] .goog.async.run.processWorkQueue [as _onTimeout] (/home/hasan/WebstormProjects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21) [object Object]出错.ElementArrayFinder.applyAction_ (/home/hasan/WebstormProjects/test/node_modules/protractor/lib/element.js:403:21) 在[object Object] .self。(匿名函数)[点击] (/home/hasan/WebstormProjects/test/node_modules/protractor/lib/element.js:76:19) 在[object Object] .self。(匿名函数)[点击] (/home/hasan/WebstormProjects/test/node_modules/protractor/lib/element.js:733:11) 在[object Object]。
参考stackoverflow Debugging "Element is not clickable at point" error的一个帖子,我一直在努力,这是我的代码
it("It should click next page botton" + pageIndex, function() {
pageIndex++;
//var nextPageSelector = element(by.id("pageNavigator_" + pageIndex));
var nextPageSelector = element(by.xpath('//li[@class="next"]/a'));
browser.debugger();
//expect(browser.isElementPresent(nextPageSelector)).toBeTruthy();
console.log("Page title: " + pageTitles.length + "Page index" + pageIndex);
if (pageIndex <= pageTitles.length) {
console.log("About to click next button");
//console.log("Co-ordinates: "+ nextPageSelector2.getCoordinates());
nextPageSelector.getLocation().then(function(buttonLocation) {
console.log("X coordinate: " + buttonLocation.x + " Y Coordinate: " + buttonLocation.y);
var sc = '"scroll(' + buttonLocation.x + ', ' + buttonLocation.y + ')"';
console.log("Statement: " + sc);
browser.actions().mouseMove(buttonLocation.x , buttonLocation.y);//.click().perform();
//browser.executeScript(sc); //
browser.wait(2000);
nextPageSelector.click().then(function() {
console.log("Successfully clicked");
browser.waitForAngular();
}, function() {
console.log("Unable to click");
});
});
}
});
我没有按住滚动到“下一页”按钮的位置。
答案 0 :(得分:1)
这个技巧对我有用:
var filterWidget = browser.findElement(by.id(widgetsId));
var scrollIntoView= function() { arguments[0].scrollIntoView(); };
browser.executeScript(scrollIntoView, filterWidget);
答案 1 :(得分:0)
您还可以在配置文件中设置窗口大小。
在protractor.conf.js中:
onPrepare: function() {
browser.manage().window().setSize(1600, 1000);
}