It's better to relay on element(link: "Services") instead of using 
link(text: "Services") because when we use link(text: "Services") WATIR 
goes on to form the xpath. xpath must be the last chance when we can't use 
any selenium locators. 

On Thursday, October 19, 2017 at 8:00:22 PM UTC+5:30, Justin Ko wrote:
>
> :link and :link_text are Selenium-WebDriver locators. Their support is 
> quite limited in Watir. They are only accepted when using the #element 
> method:
>
> browser.element(link_text: "Services").exists?
> #=> true
>
> browser.element(link: "Services").exists?
> #=> true
>
> Instead, I would suggest using :text:
>
> # using :text allows you to use the other element methods
> browser.link(text: "Services").exists?
> #=> true
>
> # exact text match
> browser.element(text: "Services").exists?
> #=> true
>
> # partial text match (which is not supported by :link_text and :link)
> browser.element(text: /Ser/).exists?
> #=> true
>
> - Justin
>
>
> On Thursday, October 19, 2017 at 10:16:21 AM UTC-4, [email protected] 
> wrote:
>>
>> I have some automation running and when I use link_text or link as the 
>> means to locate elements, I get:
>>
>> Watir::Exception::MissingWayOffFindingObjectException
>> invalid_attribute :link_text
>>
>> The same applies for :link.
>>
>> More broadly, let's say you have links that look like this:
>>
>> <a href="/services">Services</a>
>>
>> How would you generally go about finding that, assuming you didn't want 
>> to use XPath? Maybe I'm just trying the wrong locators.
>>
>>

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