Cannot find element(button)

126 views
Skip to first unread message

baghzaad...@nextgen.net

unread,
Oct 24, 2014, 2:37:04 AM10/24/14
to seleniu...@googlegroups.com
Hi,

Selenium throws error  script-exception: "org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with" (line: 74)

Element is visible for all the obvious responses out there.....

Below are the details.

Selenium Script - selenium.click("css=button.btn.btn-primary");

HTML code via Inspect element

<button class="btn btn-primary" data-dismiss="modal" ng-click="saveChanges()">

    Save Changes

</button>

Selenium IDE 

Command - click
Target - css=#addressEditor > div.modal-footer.ng-scope > button.btn.btn-primary

XPATH  -  id('addressEditor')/x:div[3]/x:button[3]

Thanks,

Baghzaad

PeterJeffreyGale

unread,
Oct 24, 2014, 5:35:14 PM10/24/14
to seleniu...@googlegroups.com
Perhaps there is a preceeding element which also matches your search criteria and which is invisible?

Narendra Kumar Singh

unread,
Oct 25, 2014, 4:29:08 AM10/25/14
to seleniu...@googlegroups.com

If you are using below command in for loop or any loop then you need to again fetch the webelement inside the loop once again this is because by clicking on button first time , it refresh the page thus you required to again fetch the webelement.

selenium.click("css=button.btn.btn-primary");

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7a6a270e-6e89-4106-b3cf-abdc9a79c848%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Doug Dragon

unread,
Oct 25, 2014, 2:15:57 PM10/25/14
to seleniu...@googlegroups.com
I would check the page first to see if the element is visible and can be interacted with.

Go to the page in question. Open up console (Chrome and Firefox both have one). Enter the following:
$$("button.btn.btn-primary")

This will locate the css element. If the console is able to find the element, Selenium should too. 

I hope that helps,

-Doug

Doug Dragon

unread,
Oct 25, 2014, 2:29:24 PM10/25/14
to seleniu...@googlegroups.com
Correction:
$$("button.btn btn-primary")

If that doesn't work you could also try:
$$("button.btn-primary")

 
-Doug 

baghzaad...@nextgen.net

unread,
Oct 26, 2014, 6:34:09 PM10/26/14
to seleniu...@googlegroups.com
Hi Doug,

$$("button.btn-primary") works on console but selenium still cant find it. could  data-dismiss="modal" be the issue here... if so then how do i go about solving this.

Thanks,

Baghzaad

baghzaad...@nextgen.net

unread,
Oct 26, 2014, 10:19:45 PM10/26/14
to seleniu...@googlegroups.com
Hi All,

Issue is now fixed.....

selenium.click("//div[@id='addressEditor']/div[3]/button[3]");

Cheers,

Baghzaad

Doug Dragon

unread,
Oct 27, 2014, 3:39:36 PM10/27/14
to seleniu...@googlegroups.com
Nice work. Glad you got it figured out. :)

-Doug

Baghzaad Bhomisha

unread,
Oct 27, 2014, 5:39:29 PM10/27/14
to seleniu...@googlegroups.com
yeah doug...but i have another complicated one....could u have a look at that...

Doug Dragon

unread,
Oct 27, 2014, 9:11:08 PM10/27/14
to seleniu...@googlegroups.com
Ha ha, well I'll certainly give it a try ;-)
What's going on now?

-Doug
Reply all
Reply to author
Forward
0 new messages