Not able to click elements which are present down [bottom] the page.

82 views
Skip to first unread message

Bhavesh

unread,
Dec 15, 2017, 1:13:17 AM12/15/17
to Selenium Users
Setup : 
selenium = 3.4.0  (pip installer)
gecko driver = 0.19
chrome driver = 2.33
Firefox browser = 57.0
chrome  browser = 63


Issue :  

I have a page, and there is a button on this page.
when this button is clicked, it opens a window/dialog, which have couple of other elements like text fields, radio box, select box etc.
Problem is, im not able to click elements which are not visible right now.  I mean these elements are present in that window but i can see them only when i scroll down.

I have simple code which click this : 

        form2.pol_sched_combobox.click()
        form2.pol_sched_combobox.select('Weekly')

This happens only for Firefox browser. This works fine for Chrome.

Error it displays is : 

StaleElementReferenceException: Message: The element reference of <input id="ext-gen1275" class="x-form-field x-form-text x-form-empty-field x-trigger-noedit"> stale: either the element is no longer attached to the DOM or the page has been refreshed

Although page is not refreshed. i can see element is present if i scroll down.

Note : If i manually scroll down before script reaches these elements, then script is able to identify and click elements.  so im very clear that issue is elements are not visible to script because they are present at lower botton of the page.


This is the issue im getting after i did the upgrade to latest driver and selenium.
This used to work fine when i have selenium 2.53.1 and firefox 46.

what is the solution for this?

Message has been deleted

Annie Costa

unread,
Dec 15, 2017, 4:35:36 AM12/15/17
to Selenium Users
Hi,

I faced the same problem and so any time i want to interact with an element, i scroll on it to be sure it is available on the "screen view":

     public static void ScrollToElt(IWebElement element)
     {
         var js = (IJavaScriptExecutor)CurrentDriver;
         js.ExecuteScript("arguments[0].scrollIntoView()", element);
     }

adithya vardhanreddy

unread,
Dec 15, 2017, 8:35:12 AM12/15/17
to Selenium Users

Actually in Chrome IF the web element is not in view port rage we face this issue. To avoid this issue we need to do scroll ,

((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", wb);

But in Fire fox and IE the scroll will happen automatically. We no need to do scroll explicitly. 

Annie Costa

unread,
Dec 15, 2017, 8:44:27 AM12/15/17
to Selenium Users
I'm using FF and the scroll is not always done. I had to add this to make it work

Bhavesh

unread,
Dec 18, 2017, 12:12:48 AM12/18/17
to Selenium Users
Thanks Annie and Adithya for the response.

So in my case issue only happens with Firefix,  chrome and other browsers everything works fine.

so i used this to scroll till the element is present, and then i see script is able to click it.

        element = self.driver.find_element_by_xpath("//label[text()='Scheduled']")
        self.driver.execute_script("return arguments[0].scrollIntoView();", element)

Yes for now, things are working and i canm proceed.

However issue is only happening after upgrade. i mean this use to work fine when  i have selenium 2.53.1 with firefox 46.  but now when i have selenium 3.4.0 with gecko driver 0.19 and firefox 57.0, it is troubling me.

Anyways thanks again for your responses.

Bhavesh
Reply all
Reply to author
Forward
0 new messages