How to bypass problem with Element is not currently visible...

3,987 views
Skip to first unread message

Adam Matłacz

unread,
Jan 7, 2016, 6:27:33 AM1/7/16
to robotframework-users
I have a long form which I have to fill in with different data.
When I perform action

self.click_element(<selectorn>)

on an element that is not "optically" visible on the site (but is loaded to the page) and run tests i receive message:
"ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Stacktrace:
    at fxdriver.preconditions.visible..."

The element is on the page but robot just can't "see" it. When i googled this problem, people suggest to scroll down to this element and then perform click_element - but I don't know how to do it with robot.
Is there other way to bypass this problem?
Or do you know, how to find element and scroll to it with robotframework (I use pageobjects)?

Adam Matłacz

unread,
Jan 7, 2016, 7:47:36 AM1/7/16
to robotframework-users
Temporary solution is to add:
self.execute_javascript('window.scrollBy(0,200)')

But this is poor solution... If anything changes in the layout of the form, all the tests have to be updated... :(
Can anybody help?

Tatu Aalto

unread,
Jan 7, 2016, 10:58:40 AM1/7/16
to amat...@gmail.com, robotframework-users

Ugh

The problem is purely selenium related and has not anything to do with the Robot Framework. Also, usually, scrolling does not work, because selenium will automatically scroll the element to the visible area in the browser. But if you have ribbon in the page, which is hidden when scroll is performed, a small scroll could help.

The stack trace is very small and leaves out vital information, but it seems that you are using Firefox. Have you tried with older versions of Firefox, the latest support version (before x-mas) by selenium was 38. Also try with chrome too, just to see is it a Firefox related problem.

Your code snippet is quite small, but I am assuming that the `click_element ` function does search the element and then does something like this: element.click(). The problem boils down to two things.

1) How do you search the element? Do you get a list of elements or a single element? If you get a list of elements, does the list contain one or more elements?

2) Are you sure that selector is correct? Which means, the selector is unique for that page? And you are sure that the correct page is visible, before you call the `click_element ` with your selector.

As a site note, is there a reason why you are not using Selenium2Library?

-Tatu
Send from my mobile

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Adam Matłacz

unread,
Jan 8, 2016, 5:31:34 AM1/8/16
to robotframework-users, amat...@gmail.com
I'm using Selenium2Library plus PageObjects. I'm first building library of key words with selectors and base on this I create TC and TS.

1. To search for element I use selectors. I use 3 types of selectors:
- select item by ID
- select item by CSS selector
- select item by xpath
First in the class I define list of selectors of items on the form. Then I use Selenium2Library to perform actions on this elements - i.e. click_element = from Click Element Selenium2Library.
In this case
"<selector>":"id=some_element_ID",
If this element is "visible" then this works smooth. But if the element is "down" on the webpage and is not "visible" on the screen, then I have error. I heard fev times, that Selenium scrolls to the element automatically and it does for some methods. For example when i use:
self.input_text("<selector>", <imput_value>) 
Selenium finds element and scrolls automatically. But this seems to not work with method Click Element! :(

2. Yes, the selector is correct. Because:
- I first test my selectors with firepath for firefox add on
- When I scroll down by javascript, then Click Element with my selector - it works fine. But as I said - this is crappy solution. If element will be moved to the different place on the page, my tests will break.

Full stack trace:
"ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Stacktrace:
    at fxdriver.preconditions.visible (file:///.../webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/component
s/command-processor.js:9981)
    at DelayedCommand.prototype.checkPreconditions_ (file:///.../webdriver-py-profilecopy/extensions/fxdriver@googlecode
.com/components/command-processor.js:12517)
    at DelayedCommand.prototype.executeInternal_/h (file:///.../webdriver-py-profilecopy/extensions/fxdriver@googlecode.
com/components/command-processor.js:12534)
    at fxdriver.Timer.prototype.setTimeout/<.notify (file:///.../webdriver-py-profilecopy/extensions/fxdriver@googlecode
.com/components/command-processor.js:621)"
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Tatu Aalto

unread,
Jan 8, 2016, 10:33:07 AM1/8/16
to Adam Matłacz, robotframework-users

Ugh

I use Click Element keyword many times in my tests and selenium does always perform scrolling. But I use the Firefox version which is supported by selenium and last I did check, the supported version is 38. Which Firefox version you are using? Also trying with Chrome, to rule out Firefox specific issues, is good practice.

-Tatu
Send from my mobile

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Adam Matłacz

unread,
Jan 11, 2016, 4:43:30 AM1/11/16
to robotframework-users, amat...@gmail.com
Ok, that is very good tips!

I will:
1. Update robot and selenium version - if this will not work...
2. I will try with other web browsers.

Will keep you posted what i discovered :)

W dniu piątek, 8 stycznia 2016 16:33:07 UTC+1 użytkownik Tatu Aalto napisał:

Ugh

I use Click Element keyword many times in my tests and selenium does always perform scrolling. But I use the Firefox version which is supported by selenium and last I did check, the supported version is 38. Which Firefox version you are using? Also trying with Chrome, to rule out Firefox specific issues, is good practice.

-Tatu
Send from my mobile

On 8 Jan 2016 12:31 p.m., "Adam Matłacz" <amat...@gmail.com> wrote:
I'm using Selenium2Library plus PageObjects. I'm first building library of key words with selectors and base on this I create TC and TS.

1. To search for element I use selectors. I use 3 types of selectors:
- select item by ID
- select item by CSS selector
- select item by xpath
First in the class I define list of selectors of items on the form. Then I use Selenium2Library to perform actions on this elements - i.e. click_element = from Click Element Selenium2Library.
In this case
"<selector>":"id=some_element_ID",
If this element is "visible" then this works smooth. But if the element is "down" on the webpage and is not "visible" on the screen, then I have error. I heard fev times, that Selenium scrolls to the element automatically and it does for some methods. For example when i use:
self.input_text("<selector>", <imput_value>) 
Selenium finds element and scrolls automatically. But this seems to not work with method Click Element! :(

2. Yes, the selector is correct. Because:
- I first test my selectors with firepath for firefox add on
- When I scroll down by javascript, then Click Element with my selector - it works fine. But as I said - this is crappy solution. If element will be moved to the different place on the page, my tests will break.

Full stack trace:
"ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Stacktrace:
    at fxdriver.preconditions.visible (file:///.../webdriver-py-profilecopy/extensions/fxdriver...@googlecode.com/component
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

mr

unread,
Feb 24, 2016, 4:20:17 AM2/24/16
to robotframework-users, amat...@gmail.com
Hi Adam!
Could you report what you discovered?

Andrea Bisello

unread,
Feb 24, 2016, 12:04:24 PM2/24/16
to robotframework-users, amat...@gmail.com
i normally setup library with 15 15 timeout in order to give time to browser to render the page.



Reply all
Reply to author
Forward
0 new messages