Dude McBro
Dude McBro

Reputation: 11

Selenium Element Cannot Be Scrolled Into View: (34). Using NUnit, C#

Getting the error from the title when attempting to click on an <a> tag in a regression test script. I've researched the issue here: Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Element cannot be scrolled into view:[object HTMLSpanElement] and here as well: https://groups.google.com/forum/#!msg/webdriver/R2jwSWrIK44/RaCLRPlKIWEJ but I don't understand the root cause of the issue.

I've tried using By.jQuery, By.Id, By.Css, By.Xpath, as well as selecting by index and always get the same error. Here's the relevant code:

HTML:

<div id="divTabs">
    <a id="tabECheck" target="#divECheck">eCheck</a>
    <a id="tabAceComments" target="#divAceComments">Ace Comments</a>
    <a id="tabReviewComments" target="#divReviewComments">Review Comments</a>
    <a id="tabReviewHistory" target="#divReviewHistory">Review History</a>
</div>

CSS:

#divTabs{
    writing-mode: tb-rl; 
    -webkit-transform: rotate(90deg);   
    -moz-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    -o-transform: rotate(90deg);
    transform: rotate(90deg);
    position: absolute;
    width: 27px; 
    padding: 0px; 
    height: auto;
    display: table-row;
    margin-bottom: 10px;
}

#divTabs a
{
    border: 1px solid #CCC;
    padding: 3px;
    white-space: nowrap;
    cursor: pointer;
    color: #3966BF;
    display: table-cell;
    background-color: #FFF;
}

C#:

element = driver.FindElement(By.Id("tabReviewComments"));
element.Click();

As you can see, I'm trying to click on the 3rd <a> tag with the id of "tabReviewComments." However, if I have the script click on the first <a> tag with the id of "tabECheck", it works in the sense that I don't get the "can't scroll element into view" error, the element is clicked, and the script moves on past that line. Sadly, I need to click on that third <a> tag. Any ideas short of moving the <a id="tabReviewComments" target="#divReviewComments">Review Comments</a> to the top?

Thanks!

Upvotes: 1

Views: 2097

Answers (1)

tfforums
tfforums

Reputation: 58

Its likely that the element is actually un-clickable as far as the browser goes, this may be because

  • Its position is off-screen (negative space)
  • Its behind another element (like modal overlay or something)
  • It has 0 size (sometimes css can be funny, browser maybe calculating size differetnlty to what your seeing)
  • A UI bug in your system whereby the element isn't visible for another reason

Upvotes: 1

Related Questions