A few recommendations from this thread.

1. Minimize the usage of `@browser.text` it results in more overhead
than necessary and is more likely to provide brittle results (if at
some point something else on the page says "English" for instance).
Locate the exact element you want, or at least a smaller section of
page to check for this.

2. Minimize usage of :visible_text as a selector, especially if you
can locate it uniquely by other means.

3. Avoid using Assertions in Page Objects. If you want a test to fail
as a result of something not being in the desired state, raise an
exception. An assertion should be used only as a way to determine the
intent of the one thing the test is validating.

On Thu, Jun 14, 2018 at 8:32 AM Derick <[email protected]> wrote:
>
> I do something like this if I want to see an element or text is present or not
>
> `expect(@browser.div(id: language-selection, visible_text: 
> 'English').present?).to be true` (or false)
>
> I also learned if you add the class id or name, it goes much more quickly 
> instead of just visible_text.
>
> Hope that helps.
>
> On Wednesday, June 13, 2018 at 10:40:40 AM UTC-7, christina wrote:
>>
>> Hi all!
>>
>> This should be so simple but not sure why it fails.
>>
>> I have this
>>
>> @browser.text.include? "English"
>>
>>
>> and it returns fals. This is correct. Can one help me how do I do an 
>> assertion to pass or fail?
>>
>> I try:
>>
>>
>> expect(@browser.text.include?("English")).to be false
>>
>>
>>
>> But at run I get
>>  Then English French Language Option should not show
>>       undefined method `expect' for #<Watir::Browser:0x00000000042d7040>
>>       Did you mean?  exec (NoMethodError)
>>       ./features/support/pages/loginClientPage.rb:13:in 
>> `login_language_option_not_exist'
>>       ./features/step_definitions/clientSteps.rb:13:in `/^English French 
>> Language Option should not show$/'
>>       features/features/client.feature:6:in `Then English French Language 
>> Option should not show'
>>
>> Thank you!
>>
> --
> --
> Before posting, please read 
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
> 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 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
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