1

I've already looked into the thread here: Debugging "Element is not clickable at point" error and Selenium webdriver can't click on a link outside the page which goes to suggest to use some javascript scrolling to the element.

The question I have may just be a waste of breath as I await the developer to fix the underlying bug of the fact that I cannot scroll this part of the page.

During the run of my selenium test, I try to click on an element that is out of the window area (and it can't scroll, that is the bug I know about). My question is, for Selenium webdriver tests, can you only click on elements that are in the viewable area and you cannot scroll to?

Or is it pretty much failing (rightfully so, because of the bug) and selenium works purely with what is visible on the screen?

Thanks, hopefully it's a bit clear.

Community
  • 1
  • 1
Th3sandm4n
  • 809
  • 4
  • 13
  • 23
  • 2
    I believe Selenium is designed to interact with the web page the way a user would, so if an element is not scrolled into view, Selenium will not interact with it. You probably can use javascriptExecutor to click it if you really need to. – Richard Jun 03 '14 at 16:48
  • Even the JavaScriptExecutor in the links above do not work (probably because you can't scroll that part of the page all. Like you said, I believe it is designed to interact also, but I am in no way an expert (day 4 of messing around with it for a few hours). – Th3sandm4n Jun 03 '14 at 17:03
  • I don't think so. I have few scripts which clicks on the links at the bottom of the page which is clearly not on the viewable area – Purus Jun 03 '14 at 17:08
  • @Purus, when you run them does it scroll them into the viewable area and then click? Because, in my case, it's impossible to get them on the viewable area (a bug in the dev code). Because I'm trying the scrolling JavaScriptExecutor code and it still fails since it can't scroll. – Th3sandm4n Jun 03 '14 at 17:25
  • Yes. It automatically scroll down to the bottom and click on the required element. BTW I run using Firefox and IE. The links provided by you says it's a bug in Chrome. Please verify. – Purus Jun 03 '14 at 17:34
  • Yup, I'm running in chrome (that's the browser we use for this set of tests). I think, though, since I can't scroll at all the workaround provided there doesn't help because it can't scroll. So, I think I'm just stuck until the page gets fixed. So, I guess this test kind of worked since it's a real issue that I can't scroll. – Th3sandm4n Jun 03 '14 at 17:41
  • A successful test is one that reveals a bug! – Richard Jun 03 '14 at 20:24

1 Answers1

0

I once had a combo box that wasn't in view that I needed to expand. What I did was use the Actions builder because the moveToElement() function will automatically scroll the object into view. Then it can be clicked on.

WebElement element = panel.findElement(By.className("tabComboBoxButton"));

Actions builder = new Actions(this.driver);

builder.moveToElement(element);
builder.click();
builder.build().perform();

(panel is simply a wrapped element in my POM)

Bill Thayer
  • 321
  • 2
  • 9