I'd need to see the html to see why it works for one of the locator
strategies, but not the other.

On Mon, Mar 27, 2017 at 1:21 PM, Raja gopalan <[email protected]>
wrote:

> Here is the code
>
>
>
> require 'watir'
> class AirTelRecharge
>  def initialize
>  caps = Selenium::WebDriver::Remote::Capabilities.firefox(marionette:
> false)
>  @b=Watir::Browser.new :firefox, desired_capabilities: caps, profile:
> "default"
>  @b.goto "https://www.airtel.in/";
>  @[email protected]
>  @driver.manage.timeouts.implicit_wait=10
>  end
>
>  def execute
>  @b.element(:text, 'Pay & Recharge').click
>  @driver.find_element(:link,'Recharge').click #Here is the problem this
> code doesn't work for @b.element(:text,'Recharge').click
>  end
> end
>
> AirTelRecharge.new.execute
>
>
>
> On Monday, March 27, 2017 at 8:48:37 AM UTC-7, Titus Fortner wrote:
>>
>> Those two locators should find the same element, but it appears it is not
>> if one says the element exists but is not visible and the other says it is
>> visible. To figure out why it is finding a different element, I'd need to
>> see the underlying html.
>>
>>
>> On Sunday, March 26, 2017 at 11:38:52 PM UTC-5, Raja gopalan wrote:
>>>
>>> Link is clearly visible to click
>>>
>>> If I write
>>>
>>> @b.link(:text,'Recharge').click
>>>
>>> WATIR converts this code into
>>>
>>> @driver.find_element(:xpath,"//a[normalize-space()='Recharge']").click
>>>
>>> but this selenium code says that element is not visible, So it's not
>>> working.
>>>
>>> If I write the following selenium code
>>>
>>> @driver.find_element(:link,'Recharge').click
>>>
>>> It works properly.
>>>
>>> Do you understand me now?
>>>
>>>
>>>
>>> On Sunday, March 26, 2017 at 3:05:51 PM UTC-7, Titus Fortner wrote:
>>>>
>>>> Is Watir finding a different link? Or is Selenium just allowing the
>>>> user to click a link that is not displayed?
>>>>
>>>> There are definitely ways that Watir can optimize its locator
>>>> strategies, but that part of the code is not trivial to dig into. As
>>>> always, pull requests are welcome.
>>>>
>>>> On Sun, Mar 26, 2017 at 12:18 PM, Raja gopalan <[email protected]>
>>>> wrote:
>>>>
>>>>>
>>>>> I have written the following selenium code to click this link
>>>>>
>>>>> @driver.find_element(:link,'Recharge').click
>>>>>
>>>>> It successfully clicks the line
>>>>>
>>>>>
>>>>> I have written the same code in WATIR as shown below
>>>>>
>>>>>
>>>>> @b.link(:text,'Recharge').click
>>>>>
>>>>>
>>>>> but it throws element not present error
>>>>>
>>>>>
>>>>> I checked out how this above code works, this above code forms this xpath 
>>>>> at the end
>>>>>
>>>>>
>>>>> "//a[normalize-space()='Recharge']"
>>>>>
>>>>>
>>>>> So I suspected that this xpath might be the reason, So I have written
>>>>> the below selenium code using this xpath, As I expected the same error was
>>>>>
>>>>> thrown by selenium as well(element is not visible)
>>>>>
>>>>>
>>>>> @driver.find_element(:xpath,"//a[normalize-space()='Recharge']").click
>>>>>
>>>>> So what I think is, WATIR should refrain forming the xpath when b.link is 
>>>>> called, they can directly convert this code to 
>>>>> @driver.find_element(:link,'Recharge') but they
>>>>>
>>>>> can form the xpath when b.element(:text,'Recharge') is called
>>>>>
>>>>>
>>>>> any suggestion?
>>>>>
>>>>>
>>>>> --
>>>>> --
>>>>> 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.
>>>>>
>>>>
>>>> --
> --
> 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.
>

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

Reply via email to