How to click hidden button use selenium2library

4,167 views
Skip to first unread message

Lane

unread,
Jan 8, 2014, 12:47:19 AM1/8/14
to robotframe...@googlegroups.com
I manually can click this button, but use selenium2library will get element not found.

There are any way to click this button?

html:
<span id="Wireless_enable0" class="bt_radio" style="background-position: 0px -18px;"></span>
<input type="radio" id="Wireless_enable" name="Wireless_enable" value="1" lang="1" checked="" style="visibility: hidden;">
<label for="yes">Yes</label>

Paweł Broda

unread,
Jan 8, 2014, 7:40:45 AM1/8/14
to robotframe...@googlegroups.com
If you can see the button Selenium should see it too. Do you run test on your machine or on some remote server? If latter, then try to check if the button is actually visible in browser (I once ran into problems due to low screen resolution on test server - some buttons were not visible in small browser window). Maybe this will help you.

David

unread,
Jan 8, 2014, 8:35:25 PM1/8/14
to robotframe...@googlegroups.com
You could use Selenium2Library keyword for executing javascript. Then execute javascript that changes the DOM element from visibility hidden to not (whatever the appropriate value is), then you should be able to click the element.

But that's a last resort option if you really must click it (and the button happens to be set invisible). Or maybe you're not clicking the actual element, it may be another one that's adjacent that is "visible" that you're supposed to click, not the hidden one, as it's hidden for a reason.

Lane

unread,
Jan 8, 2014, 9:20:46 PM1/8/14
to robotframe...@googlegroups.com
Hi David,

I don't know how to use execute javascript to changes the DOM element from visibility hiddent to visible.
Have example according to my html code?

David於 2014年1月9日星期四UTC+8上午9時35分25秒寫道:

Kevin O.

unread,
Jan 8, 2014, 10:00:34 PM1/8/14
to robotframe...@googlegroups.com
> I manually can click this button, but use selenium2library will get element not found.
Is this really true or are you getting an ElementNotVisibleException?

Like David was saying, manipulating the AUT should be a last resort.
When you inspect the element that you click on using Firebug, etc., which element is actually highlighted, the span? That is the element you should be trying to click on. It looks like your AUT might have an event listener on another element and toggles the value of the input element when the other element gets an onClick event.
There are times where I had to use Simulate instead of a Click keyword.

Lane

unread,
Jan 16, 2014, 9:27:57 PM1/16/14
to robotframe...@googlegroups.com
FAIL : ValueError: Element locator 'xpath=//input[@type='radio' and @name='Wireless_enable']' did not match any elements

Kevin O.於 2014年1月9日星期四UTC+8上午11時00分34秒寫道:

Kevin O.

unread,
Jan 16, 2014, 10:03:09 PM1/16/14
to robotframe...@googlegroups.com
XPath seems correct to find element in the HTML fragment from your earlier post. Either the element is not there when this is run or it is in a frame/iframe.
Have you tried using the Wait Until keywords?

Lane

unread,
Jan 16, 2014, 10:12:04 PM1/16/14
to robotframe...@googlegroups.com
You are right!!  I have no select to correct frame.

Now, I select frame will get error.

FAIL : 
ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: 
    at fxdriver.preconditions.visible (file:///c:/users/dell/appdata/local/temp/tmp8v71lm/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:8231)
    at DelayedCommand.prototype.checkPreconditions_ (file:///c:/users/dell/appdata/local/temp/tmp8v71lm/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10823)
    at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/dell/appdata/local/temp/tmp8v71lm/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10840)
    at DelayedCommand.prototype.executeInternal_ (file:///c:/users/dell/appdata/local/temp/tmp8v71lm/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10845)
    at DelayedCommand.prototype.execute/< (file:///c:/users/dell/appdata/local/temp/tmp8v71lm/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10787

Kevin O.於 2014年1月17日星期五UTC+8上午11時03分09秒寫道:

Kevin O.

unread,
Jan 16, 2014, 10:45:47 PM1/16/14
to robotframe...@googlegroups.com
As a user, you cannot interact with hidden elements. WebDriver refuses to do so because it is trying to be a realistic test tool.
Whatever you have to do to get the element to become visible as a human with a mouse, you will have to do the same in the automation. Sometimes the automation is to fast, so the Wait Until Element Is Visible keyword may help there.

Lane

unread,
Jan 16, 2014, 11:36:17 PM1/16/14
to robotframe...@googlegroups.com
I can use mouse to click this checkbox, but still show hidden in html code.
I have use sleep to make sure page is displayed when run robot.
This html code is our design by our produce. Is not this html code is design wrong? I can tell our engineers to modify this code, but if automation can do, this code will not need to be modify.





Kevin O.於 2014年1月17日星期五UTC+8上午11時45分47秒寫道:

Tatu Aalto

unread,
Jan 17, 2014, 1:48:48 AM1/17/14
to nkc24...@gmail.com, robotframework-users

Ugh

Have you used Firebug [1], or similar tool, to verify the number of matching elements? Because Selenium2library is designed to take the first matching element from the DOM tree and interact with that element.

Because if you say that you can see and click the elements but the element is hidden from the html code,  then you are looking/referring to the wrong element or something very weird is going on. In any case consulting your developer is a good idea. Because sometimes the DOM tree can be quite messy to read and understand.

-Tatu
[1] http://getfirebug.com

--
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 http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/groups/opt_out.

Lane

unread,
Jan 17, 2014, 2:14:27 AM1/17/14
to robotframe...@googlegroups.com, nkc24...@gmail.com
1. Radio Button Should Be Set To | Wireless_enable | 1
Get Pass.

2. Select Radio Button | Wireless_enable | 1
Get FAIL : ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: 

Tatu Aalto於 2014年1月17日星期五UTC+8下午2時48分48秒寫道:

Ugh

Have you used Firebug [1], or similar tool, to verify the number of matching elements? Because Selenium2library is designed to take the first matching element from the DOM tree and interact with that element.

Because if you say that you can see and click the elements but the element is hidden from the html code,  then you are looking/referring to the wrong element or something very weird is going on. In any case consulting your developer is a good idea. Because sometimes the DOM tree can be quite messy to read and understand.

-Tatu
[1] http://getfirebug.com

On 17 Jan 2014 06:36, "Lane" <nkc24...@gmail.com> wrote:
I can use mouse to click this checkbox, but still show hidden in html code.
I have use sleep to make sure page is displayed when run robot.
This html code is our design by our produce. Is not this html code is design wrong? I can tell our engineers to modify this code, but if automation can do, this code will not need to be modify.





Kevin O.於 2014年1月17日星期五UTC+8上午11時45分47秒寫道:
As a user, you cannot interact with hidden elements. WebDriver refuses to do so because it is trying to be a realistic test tool.
Whatever you have to do to get the element to become visible as a human with a mouse, you will have to do the same in the automation. Sometimes the automation is to fast, so the Wait Until Element Is Visible keyword may help there.

--
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.

suhayla...@gmail.com

unread,
Feb 5, 2018, 9:59:21 PM2/5/18
to robotframework-users
Did you manage to solve this?
Reply all
Reply to author
Forward
0 new messages