Encountering an error while trying to click on an <a>
tag in a regression test script, resulting in the issue mentioned in the title. I have delved into the problem both here: Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Element cannot be scrolled into view:[object HTMLSpanElement] and also here: https://groups.google.com/forum/#!msg/webdriver/R2jwSWrIK44/RaCLRPlKIWEJ, but the root cause of the problem eludes me.
I've attempted various methods such as By.jQuery, By.Id, By.Css, By.Xpath, and selecting by index, only to face the same error repeatedly. Here's the relevant code snippet:
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();
It is evident that I am attempting to click on the third <a>
tag with the id "tabReviewComments." However, clicking on the first <a>
tag with the id "tabECheck" works without any scroll-related errors, allowing the script to proceed successfully. Regrettably, the requirement mandates clicking on the third <a>
tag. Any suggestions other than reordering the tags?
Appreciate your insights!