1
votes

I'm using Robotframework selenium2Library with python base and Firefox browser for automating our web application. Having below issue when ever a Click event is about occur,

Header in the web application is immovable during page scroll(ie., whenever page scroll happens header would always be available for user view, only the contents get's scrolled) now the issue is, when a element about to get clicked is not available in page view, click event tries to scroll page to bring the element on top of the webpage,which is exactly below the header(overlap) and click event never occurs, getting below exception.

WebDriverException: Message: Element is not clickable at point (1362.63330078125, 15.5). Other element would receive the click: https://url/url/chat/chat.asp','popup','height=600, width=680, scrollbars=no, resizable=yes, directories=no, menubar=no, status=no, toolbar=no'));">

I have tried Wait Until Page is Visible keyword, but still this doesn't help, as the next statement, Click event(Click Element, Click Link etc) is again scrolling up to the header.

Header being visible all time is a feature in our web application and due this scrips are failing, Can some one please help to over come this issue and make the click event to get executed successfully?

3
what if, as for debugging purposes to add a Sleep 30s to your page, before executing the Click itself? Also a Capture Page Screenshot could help, if you are able to see what is on the page excatly when the test fails.Richard Zilahi
I have tried adding a sleep before Click, but as a next step while Click event is getting executed, page is getting scrolled on top(just below the header bar). Capture page screenshot is showing the element to be clicked is hidden by the header.Vidhya Lakshmi Shankarlal
Then the problem is found! if the header hides the element you wish the click, an other element gets the click excatly as the issue says. You need to solve the covering problem first...Richard Zilahi
Yes, that is the issue I'm trying to resolve. The header visibility all time is a feature in our application. Is there a way to resolve this?Vidhya Lakshmi Shankarlal

3 Answers

1
votes

So if I understand correctly, when you click an element page scrolls down just enough so it is visible. Because you have a transparent header, element stays under it and cannot be clicked. My solution would be to make a new keyword that scrolls down until element is visible and then scroll down a bit more.

*** Settings ***
Library      Selenium2Library

*** Keywords ***
Scroll And Click
    [Arguments]           ${element}
    Execute Javascript    window.document.evaluate("//*[@id='${element}']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.scrollIntoView(true);
    Execute Javascript    window.scrollBy(0, -200)
    Click Element         ${element}

*** Test Cases ***
Scrolltest
    Open Browser        http://www.stackoverflow.com/    gc
    Scroll And Click    hireme
0
votes

If you know the element is clickable and just want to click anyway, try using Click Element At Coordinates with a 0,0 offset. It'll ignore the fact that it's obscured and will just click.

0
votes

We can use the Execute JavaScript to click the element. I am using this in Python3.

${Element} = Get WebElement | xpath=//input[@id=image]
Execute JavaScript | arguments[0].click();  | ARGUMENTS  |  ${Element}

Reference to use ID/xpath as web locator: Robot Framework: Click Element using Execute JavaScript