Need help in clicking element which is behind the footer of the page

2,659 views
Skip to first unread message

Anand

unread,
Jan 9, 2014, 9:02:27 PM1/9/14
to webd...@googlegroups.com
Hello guys,

My problem is that the footer of the website stays fixed and it overlaps some of the main area on the page when we scroll down.
When the element is not in the view area, selenium tries to scroll the page until it appears in the view area. 
Problem is that the footer covers that element to some extent hence, when selenium clicks, the click goes on footer instead of the element. 

I need to find a way to scroll beyond what selenium automatically scrolls. 

I know I should probably ask developer to set that footer not to overlap the main area but before that I thought I should seek some advice on the group. 

My page looks something like this : 

Grey part is the footer part. There's a button behind.


Now, selenium will scroll the page only till here, and now when it clicks on the button, the click is getting received by the footer instead. 

Note : I have deliberately taken a screen shot by scrolling down little extra to know that there indeed is a button behind. Selenium actually scrolls the page little less than what you are seeing in the picture. 

darrell

unread,
Jan 10, 2014, 7:52:10 AM1/10/14
to webd...@googlegroups.com
Selenium will normally scroll elements into view. I suspect that your implementation is some how confusing Selenium, i.e. Selenium sees the viewport as the entire screen and once it scrolls into the viewport it thinks it is visible and clickable. It might be a good test case for the Selenium team. However, until they can look at making Selenium handle it (or tell you why the code is doing something which works but it's guaranteed to) you might want to write a workaround.

You could determine the size of the footer using WebDriver. You find the footer element and from the element you can get the Dimension of it. You then findElement the button, see if the button is clickable, if not, scroll the screen by the footer height using Actions, see if the button is clickable, if not, scroll the screen, etc.

Darrell

Anand Dandekar

unread,
Jan 10, 2014, 3:21:43 PM1/10/14
to webd...@googlegroups.com
darrell,

Yes, I know it's not selenium which is performing wrongly but it's because of our page that it cannot click it. Anyway, I am trying to do as you said but it is not scrolling the page at all.
What's wrong in here ?

        public void click(By locator){
WebElement ele = driver.findElement(locator);
boolean flag = false;
while(!flag){
try{
ele = waitUntilClickable(locator, MAX_TIME_OUT);
ele.click();
flag = true;
}catch(WebDriverException wde){
System.out.println("FAILED !!!!!");
if(driver.findElements(By.cssSelector("footer.footer")).size() > 0){
WebElement footer = driver.findElement(By.cssSelector("footer.footer"));
Dimension d = footer.getSize();
System.out.println("height of the footer : " + d.height);
Actions builder  = new Actions(driver);
builder.clickAndHold(footer).moveByOffset(0, d.height).release().perform();
}
}
}
}

In fact, I tried to increase the Y offset by 10 times just to see it moves, but it didn't. 



Regards,
Anand


--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/9BDlhfpuiUc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.

SuperKevy

unread,
Jan 10, 2014, 5:13:59 PM1/10/14
to webd...@googlegroups.com
What a bug!  I bet you can manually click it by clicking the top edge.

If you can click or set focus to an object just before the button then try a send_keys ( :tab )  and send_keys( :enter ) 

Anand Dandekar

unread,
Jan 10, 2014, 5:50:43 PM1/10/14
to webd...@googlegroups.com
Hello SuperKevy,
Thanks for the reply. Actually I am not able to click on the button manually too. I have deliberately scrolled it little further in the screenshot to let you guys know there indeed is a button behind. In a real scenario when it runs, I wouldn't even see the top edge of the button. Although I know the button is there.

I have a workaround currently and I am doing 
                    for(int i=0;i<4;i++)
                    {
driver.findElement(By.tagName("body")).sendKeys(Keys.DOWN);
                    }
I know this is a cheap workaround but it is working. I will still try to convince our UI Engg to somehow avoid overlapping the main area by that footer.


Regards,
Anand

darrell

unread,
Jan 11, 2014, 10:50:19 AM1/11/14
to webd...@googlegroups.com
I was going to say, I wouldn't try moving the footer. I'd try moving something you can get to which is not blocked by the footer and move it the height of the footer. So a slight improvement on this would be change the for loop to a while loop. Do a Keys.DOWN on the body, try to click the button. If it throws an exception, stay in the while loop. The moment the button takes the click, exit the while loop.

Essentially, when you test it manually, you have to cursor down until the button is clickable. You might have noticed that it takes 4 cursor down moments for the button to become visible but REALLY you are cursoring down until the button is clickable and not always cursoring down 4 times. So your automation should try to mimic what you would do manually to get around the website design.

Anand Dandekar

unread,
Jan 11, 2014, 11:51:49 AM1/11/14
to webd...@googlegroups.com
Darrell,
Agreed. But when I first click the button in the try block, selenium scrolls the page down. Now I just need to move my cursor down a little further to expose that button fully. In fact, I won't even need more than 2 cursors down. But anyway, I have modified my code to what you suggested. Thanks for the responses. It helped. 
--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/9BDlhfpuiUc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.


--

Regards,
Anand

manoj...@brocode-inc.com

unread,
Jan 22, 2014, 11:58:57 AM1/22/14
to webd...@googlegroups.com
Hi  SuperKevy/Darrell/Anand,

I am facing the same issue with my test suite here. Instead of "click" I am trying to drag a slider (page.driver.browser.action.drag_and_drop_by(---).perform).
SeleniumStandalone JAR: 2.39.0 
IEDriverServer:2.39.0
Bindings: Ruby
Grid: Yes

Above is the image of the bottom right corner of the page that I am working on (I cant show the entire page now). 
The slide button is partially shown (the small line the below "SMallest angle displayed" label). 
Dragging it is failing silently. It is not actually dragging it or failing with exception but the test silently continues on.

If I manually scroll the element out or inside before it tries to drag, it is working (I added a sleep and scrolled). So, can say that auto-scroll is working if completely out of the view port. 

Starting with a bunch of tests, I am right now trying to get our entire test suite running in IE 8/9/10/11. There might be more failures similar to this in the whole suite.
So instead of adding workarounds for all of them, I am planning to wait till this gets fixed in selenium.
Please advice on this.

Is there any issue raised for this, where i can track the activity on it? 

How soon will a issue like this be solved and release in the selenium community?  (A guess)

Based on the answers, I can take an informed decision. 

I would be really grateful for your valuable replies. I am not a CPP guy. I could have helped with some analysis in the IEDriverServer code, if it was java or ruby.

Regards,
Manoj
Darrell,
To unsubscribe from this group and all its topics, send an email to webdriver+unsubscribe@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.


--

Regards,
Anand

Anand Dandekar

unread,
Jan 23, 2014, 11:41:57 AM1/23/14
to webd...@googlegroups.com
Hi Manoj,
This is just an imagination but could you try clicking it first before you drag it? I mean I can only think of implementing work around once you get the exception. Unless you get the exception there is no way to know that it is failing. If at all it throws one, you can do similar thing as I did to get around this problem. 

Have you tried running this on other browsers? 
--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/9BDlhfpuiUc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.


--

Regards,
Anand

Anthony Browness

unread,
Feb 11, 2014, 12:56:01 AM2/11/14
to webd...@googlegroups.com
use JavaScript to hide the footer before you try to click the element?
Reply all
Reply to author
Forward
0 new messages