简体   繁体   中英

Code works in watir-classic but not in watir-webdriver

When I write the blow code in Watir-webdriver :

$browser.checkbox(:index,0).click

It gives the following error:

element not visible (Session info: chrome=48.0.2564.97) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)

and then I have written this code $browser.input(:index,0).click then it reports this error:

unknown error: Element is not clickable at point (952, 17). Other element would receive the click: ... (Session info: chrome=48.0.2564.97) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)

But the element is clearly visible and also the given above two lines of code cleanly works in watir-classic , we do not even need to scroll the screen.

Can anyone suggest me why it is the case? Why this watir-webdriver is not as comfortable as watir-classic ?

<td class="centred"> <label class="label-checkbox"> <input type="checkbox" data-ng-model="cover.IsSelected" class="ng-pristine ng-valid"> <div class="fake-checkbox"> <span class="glyphicon glyphicon-ok"></span> </div> </label> </td>

The first thing you need to do is to update your chromedriver , as version 2.9 is 2 years old. That binary needs to be kept up to date with current versions of chrome. It is quite likely that this alone will fix your issue.

If it is an issue of visibility... The purpose of Watir (and Selenium and WebDriver) is to mimic the action of a user. If the checkbox isn't visible to the user, you shouldn't be able to click it in your test.

If the checkbox is something that isn't visible at first, but then becomes visible, you can do: browser.checkbox.when_present.click (note that index: 0 is the default behavior and is not necessary)

If the checkbox has some exciting javascript things that are covering it up in a way that it is never going to be visible, and clicking on something that is visible throws the "Element not clickable" error, you might have to do browser.checkbox.when_present.fire_event :click That method does not mimic what a user actually does on your site, so it should only be used as a last resort.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM