开发者

is there any difference between Watir Vs Watir-webdriver for handling xpath

开发者 https://www.devze.com 2023-04-06 12:54 出处:网络
Below is the html from webpage i am trying to automate, When I am using Watir, it is finding the element correctly but not with watir-webdriver.

Below is the html from webpage i am trying to automate, When I am using Watir, it is finding the element correctly but not with watir-webdriver.

  <td width="87">
  <input type="image" style="height: 34px; width: 83px; border-width: 0px;" src="/test/test/img/Order-Online-Form_18.gif" id="order1_Next1" name="$Next1">
                </td>
开发者_运维知识库

I am using the below code:

require 'rubygems'
require 'watir'
browser = watir::Browser.new
browser.goto 'test.com'
test = @browser.td(:xpath,"//input[@id='order1_Next1']").exists?
puts test

When I am using watir, it returns true but If i am using watir-webdriver, it returns false. Can you guys help me why watir-webdriver is not recognizing the xpath

Thanks


You're trying to locate a 'td' when you're looking for a 'button'.

And using a XPath selector is almost certainly the wrong way to locate this element.

You're much better off using the button element type with an id attribute:

require 'watir-webdriver'
b = Watir::Browser.start 'http://dl.dropbox.com/u/18859962/qageeks.html'
b.button(:id => 'order1_Next1').exists? # => true 
b.button(:xpath,"//input[@id='order1_Next1']").exists? # => true 

You can use the last line if you're adamant about xpath, but as you can see it's more verbose and less clear to read.

0

精彩评论

暂无评论...
验证码 换一张
取 消