Chrome browser 61v. Problems with click on element outside visible area

耗尽温柔 提交于 2019-12-24 01:39:13

问题


When I update Chrome browser to 61v, there are problems with click on not visible element outside visible area.

Earlier it worked

Try click on link outside visible area: element.Click() There is: InvalidOperationException; element not clickable at point (1134, 989)

Is there are some decisions with it? Maybe update chrome driver helps?


回答1:


We had the same issue. We were using Chromedriver version 2.31. After updating to 2.32 the issue is gone. Below is one of the changes made for 2.32: "Fixes a bug where Chromedriver fails to click due to page scrolling changes in Chrome 61+."




回答2:


I implemented a method with some JavaScript to help with those issues (scroll into view), of course it had to be implemented differently for whatever browser I was using.

Try this though:

IJavaScriptExecutor js = SeleniumDrivers.driver as IJavaScriptExecutor;

Chrome:

js.ExecuteScript("arguments[0].scrollIntoViewIfNeeded(true);", e);

Firefox & IE:

js.ExecuteScript("arguments[0].scrollIntoView(true);" +
                                     "window.scrollBy(0,-100);", e);

You don't need the "window.scrollBy" part, but I noticed it helped me a lil' more to add that part. Obviously you can set the variables to whatever works for you or remove it completely if it's not feasible for what you need it for.

This fixed most of my "outside visible area" issues.

I also later on had to add focus to the window constantly. This was really becoming a problem with IE. So this was implemented below:

driver.SwitchTo().Window(driver.CurrentWindowHandle);

It also seemed to help with Firefox as well.

Good luck!



来源:https://stackoverflow.com/questions/46154711/chrome-browser-61v-problems-with-click-on-element-outside-visible-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!