On Tuesday, July 21, 2015 at 5:24:04 AM UTC-7, Mahesh Mesta wrote:
>
> I'm using watir to perform automated testing for an application and trying
> to click on a submit button once I select options for select list and fill
> up the form.However on clicking the button, it throws element not found
> error
>
>
> The html snippet for button tag
>
> <button type="submit" class="md-primary md-raised md-button md-default-
> theme" ng-transclude=""><span class="ng-binding
> ng-scope">Submit</span><div style="" class="md-ripple-container"></div>
> </button>
>
> The ruby script
>
> require "watir"require "watir-webdriver"
> browser = Watir::Browser.new :firefox
> browser.goto 'https://54.69.254.137/webui#/landing'
> browser.driver.manage.window.maximize
> browser.button(:class =>'sign-in md-button md-default-theme').click
> browser.text_field(:id =>'input_001').set('[email protected]')
> browser.text_field(:id =>'input_002').set('password')
> browser.button(:class =>'md-primary md-raised md-button md-default-
> theme').click
> browser.input(:id =>'input_002').when_present.click
> browser.element(aria_label:'What do you want to do?').when_present.click
> browser.element(:id =>'select_option_00G').when_present.click
> browser.element(aria_label:'About what?').when_present.click
> browser.element(:id =>'select_option_00P').when_present.click
> browser.textarea(:id =>'input_00N').when_present.set('Discuss about
> javascript and later test the application??')
> browser.button(:class =>'md-primary md-raised md-button md-default-
> theme').click
>
> It throws the following error
>
> Selenium::WebDriver::Error::ElementNotVisibleError: Element is not
> currently visible and so may not be interacted with
>
>
> I tried using
>
> browser.button(:class =>'md-primary md-raised md-button md-default-
> theme').when_present.click
>
> ,but it will throw time out error.Not able to rectify the error .Plz help
> !!
>
So the error you are seeing means that webdriver itself is able to find an
element using the criteria you specified, but it believes the element is
not visible to the user (off screen, hidden, or covered by another
element). Webdriver tries very hard to not allow you to do something a
real user could not do, so while it was able to locate the element in the
DOM, if it does not believe that a user could 'see' the button it refuses
to click on it and throws the error you saw.
There are a few possibilities as to what could cause this in a case where
you can 'see' the button. The most likely is that there is more than one
button in the DOM with the class combination you specified, which is often
the case in fancy sites with multiple 'pop-up' UI elements, Tabs, etc where
DOM elements are appearing and disappearing by tweeks to their css
settings..
To check for that, you can get a count of the number of elements that match
your specification
count = browser.buttons(:class =>'md-primary md-raised md-button
md-default-theme').size
puts "there are #{count} buttons of the type we are looking for"
if the count is larger than 1, then likely watir is finding the first button
that matches (which it will in this case) but that button is hidden. You will
likely want to find a container (e.g. if the UI has tabs, the div that contains
the contents of the active tab) and specify that watir should look inside that
element to find the button you want. which might look something like
browser.div(:name => 'Tab3').button(:class =>'md-primary md-raised md-button
md-default-theme').click
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.