Chrome browser 61v. Problems with click on element

2019-07-14 00:08发布

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?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-07-14 00:59

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!

查看更多
Root(大扎)
3楼-- · 2019-07-14 01:04

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+."

查看更多
登录 后发表回答