[wtr-general] Re: Next release?

2020-08-27 Thread Justin Ko
Titus released v6.17.0 last night.

Watir still has active support. This mailing list, Stack Overflow and Slack 
usually get a response. Active development will vary based on how much free 
time the developers have - eg this past year has been pretty bad. If 
there's something you need, feel free to ask and we can see if we can get 
time for it.

Justin

On Wednesday, August 26, 2020 at 9:13:20 AM UTC-4 Deeboraha wrote:

> The last release of Watir was Dec 2018?, is there still active development 
> and support of Watir  and if so when would we expect the next build to be 
> available?  
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/f7cad242-4a74-4658-b454-35d8ca83c5c8n%40googlegroups.com.


Re: [wtr-general] Re: Elements - Multiple locators for same element

2019-12-04 Thread Justin Ko
Hi Andrei,

Do you have an example of where an OR evaluation is useful? 

As Titus said, it's not usually the way to go. That said, I'm pretty sure 
I've done it before. The solution usually depends on what you are trying to 
do and the page. For example:

   - If you wanted to match elements with the class of "A" or "B", but not 
   "C", you could use a regular expression.
   - Some times I have found that looking at an ancestor or descendant 
   element can remove the need for an OR condition.
   - If there is really nothing in common between the elements you can 
   always brute force it by creating a list of elements and using the first 
   that exists - eg found_element = [browser.div, browser.span].find(&:exists?)
   
 Justin


On Wednesday, December 4, 2019 at 9:40:37 AM UTC-5, Titus Fortner wrote:
>
> Right, I'm not a big fan of that pattern, as it makes executing 
> deterministic tests more challenging. If you want to use it to apply to 
> multiple views like mobile/desktop, you're going to introduce race 
> conditions. If you want to use it to minimize brittleness you run the risk 
> of testing the wrong thing.
>
> Requiring explicitness in this case is a feature not a bug.
>
> On Wed, Dec 4, 2019, 6:32 AM Aionitoaie Andrei  > wrote:
>
>> Thanks,
>>
>> I was looking something more like OR evaluation.
>>
>> luni, 2 decembrie 2019, 22:38:45 UTC+2, Titus Fortner a scris:
>>>
>>> Watir allows you to locate elements with multiple locators with an 
>>> implied "AND" it does not support multiple locators with an "OR" evaluation.
>>>
>>> What is supported is described here: http://watir.com/guides/locating/
>>>
>>>
>>> On Monday, December 2, 2019 at 1:17:16 PM UTC-6, Aionitoaie Andrei wrote:

 Hi,

 Does Watir has something like identifying the same element using 
 multiple locators? Something like Appium has: @AndroidFindBy and 
 @IOSFindBy?

 Or maybe some suggestions about how to achieve this?

 Thanks,
 Andrei

>>> -- 
>> -- 
>> 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.
>>  
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-...@googlegroups.com 
>> --- 
>> 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 watir-...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/watir-general/2205db86-bb17-4fb0-8f44-4c7137f65254%40googlegroups.com
>>  
>> 
>> .
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/a14ebc28-e063-4271-83f2-94a577f2d482%40googlegroups.com.


[wtr-general] Re: Watir Changing Element Collection if Negated Attribute Present

2019-09-24 Thread Justin Ko
I cannot think of why the collection would change automatically, but here 
are some things that might help debug the issue:

   1. Share the webdriver logs for the scenario (enable using 
   Selenium::WebDriver.logger.level = :info)
   2. Is "errors" a custom method or variable? The smalls accessor only 
   generates #errors_elements, so there could be an issue with how "errors" is 
   defined.
   3. Which of the errors disappear (eg the first 2, last 2, etc)? Is it 
   always the same 7 that disappear?
   4. Is the smalls accessor defined in the main page object or inside a 
   page section? 
   5. If you copy the HTML to a static .html file, does the page-object 
   have the same problem interacting with that page?
   
Justin


On Tuesday, September 24, 2019 at 8:41:45 AM UTC-4, Jeff Nyman wrote:
>
> My title for this is terrible but I can't think of a better way to word it 
> right now.
>
> I have a web screen where if you click a submit button without filling in 
> fields, 9 validation error messages appear. I have defined a page object 
> with these elements as a collection:
>
> smalls :errors, class: ["form__error", "!ng-hide"]
>
> This is using a page object model where "errors" becomes a method that can 
> be called, essentially wrapping the HTMLElements. A key thing there is I'm 
> negating a class attribute.
>
> If I do this:
>
> puts errors.count
>
> It outputs 9 correctly. So I know the element definition is referencing 
> the right collection and finding the appropriate objects with the class.
>
> However, if I do this:
>
> puts errors.count
> puts errors.count
> puts errors.count
>
> I get the following output:
>
> 9
> 2
> 2
>
> This is without any change to the page. Somehow it's losing reference to 7 
> of the errors, even though on the screen nothing has changed. I have a 
> sleep in place to make sure I can see the screen. And when I do a check in 
> the console for ".form__error", I see 9 returned and I see they have the 
> same class attributes. But somehow just calling "errors" again is losing 
> reference to some of the elements in the collection.
>
> Here's another example of how this happens.
>
> If I do this:
>
> errors.each do |error|
>   puts(error.text)
> end
>
> I get the text of all nine errors correctly, once again showing that my 
> element definition is working and finding only those elements with the 
> class. But now I'll combine the things I'm doing and do this:
>
> puts errors.count
>
> errors.each do |error|
>   puts(error.text)
> end
>
> I get an output of 9 with no error messages listed. So it only recognized 
> the "errors" on the first execution. Now I'll change the order of those:
>
> errors.each do |error|
>   puts(error.text)
> end
>
> puts errors.count
>
> In this case, I get the nine error messages text listed out but no count 
> at all.
>
> Now here's the kicker: if I remove the negated class element, everything 
> works:
>
> smalls :errors, class: "form__error"
>
> This now returns consistent results. They are wrong results unfortunately 
> because the app has some extra "form__error" text that I don't want to 
> count. I only want the "form__errors" that also not have a "ng-hide" 
> attribute as part of the class.
>
> I'm hoping I'm describing this well enough that it makes sense to someone 
> what might be happening.
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/928761d2-3d14-4ecf-a27f-3f24bfa55841%40googlegroups.com.


Re: [wtr-general] Re: Click succeeds but action as the result of that click is not triggered

2019-08-12 Thread Justin Ko
Manually (ie as a person, not automated by Watir) doing the steps, I am 
able to reproduce the problem. It happened frequently in Firefox, but could 
also be seen occasionally in Chrome. As the problem can be seen manually, 
this does not seem to be a Geckodriver, Watir or Selenium problem.

To me, it seems like a problem with loading the page. When the button 
failed in Firefox, the console had errors. The following was seen when 
loading the page:

require.js load timeout for modules: main 

The following was seen when clicking the button:

ReferenceError: Communication is not defined

Hope that helps.

- Justin


On Sunday, August 11, 2019 at 12:17:54 PM UTC-4, Titus Fortner wrote:
>
> If a sleep fixes it, it's a race condition. The rest doesn't matter.

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/3c794070-c15a-437b-adcf-faaa11aa14c3%40googlegroups.com.


[wtr-general] Re: how to convert selenium element into watir element

2019-06-20 Thread Justin Ko
There is an :element locator that takes the Selenium object:

element = driver.find_element(id: 'something')
watir_element = browser.element(element: element)

Justin


On Thursday, June 20, 2019 at 3:28:45 AM UTC-4, rajagopalan madasami wrote:
>
> I know how to convert WATIR element into selenium element 
>
>
>
> element=b.text_field
>
>
> selElement=element.wd
>
> But Is there anyway I can convert selenium element into WATIR element?
>
> Like 
>
> element=driver.find_element(id: 'something')
>
> watirElement=?
>
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/b8d9bb07-dc78-4ead-94df-9fc19f74bbfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to call the custom tags?

2019-05-29 Thread Justin Ko
Which is the working one? The code appears to be the same for both the 
working and not working one.

I assume that the working one is the original :xpath locator you were 
trying to convert. If that's the case, I would guess you are running into 
how Watir returns the first match of each individual method call rather 
than the first matching the entire series of chained methods.

For example, your Watir code should work for:


  
Label
Value
  


But it will not work for:


  
Label
another
Value
  


Notice in the failed page that there is an extra div between the label and 
div containing lf-select. The code, label(title: 'Subject').
following_sibling(tag_name: 'div'), finds the first sibling of the label, 
regardless of whether it contains the lf-select. In contrast, the :xpath 
locator does consider the div children and therefore ignores the first 
sibling.

Assuming you are in the second example, you will need to tell Watir more 
specifically which following sibling you need. 

I suppose the closest representation to the XPath, would be to iterate over 
the siblings until you find the one with the lf-select:

browser.label(title: 'Subject').following_siblings(tag_name: 'div')
  .find { |e| e.element(tag_name: 'lf-select').exists? }
  .element(tag_name: 'lf-select').div.span.text

If you know the exact position of the sibling you could simplify this to:

browser.label(title: 'Subject').following_sibling(tag_name: 'div', index: 1
).element(tag_name: 'lf-select').div.span.text

#following_sibling accepts the usual locators, so you could use whatever 
identifiable attributes it has.

Justin


On Wednesday, May 29, 2019 at 3:10:58 AM UTC-4, rajagopalan madasami wrote:
>
> I have written the following code
>
> b.label(title: 'Subject').following_sibling(tag_name: 
> 'div').element(tag_name: 'lf-select').div.span.click
>
>
>
> It throws this error of element not present
>
> But this one
>
> b.label(title: 'Subject').following_sibling(tag_name: 
> 'div').element(tag_name: 'lf-select').div.span.click
>
>
>
> works fine.
>
>
> On Tuesday, 28 May 2019 19:52:13 UTC+5:30, Titus Fortner wrote:
>>
>> I'd need to see the underlying html to know for sure, but it looks like 
>> you want to specify the tag name of the following sibling 
>> `following_sibling(tag_name: 'div')`
>>
>>
>>
>> On Tuesday, May 28, 2019 at 8:45:37 AM UTC-5, rajagopalan madasami wrote:
>>>
>>> Justin,
>>>
>>> Can you please help me to write this code in watir?
>>>
>>> b.span(xpath: 
>>> "//label[@title='Subject']/following-sibling::div/lf-select/div/span").click
>>>
>>>
>>> I have tried this
>>>
>>> b.label(title: 'Subject').following_sibling.element(tag_name: 
>>> 'lf-select').div.span.click
>>>
>>> But it's not working. 
>>>
>>> Can you help me here?
>>>
>>>
>>> On Tuesday, 28 May 2019 18:56:52 UTC+5:30, Justin Ko wrote:
>>>>
>>>> For custom elements, you will need to use the #element method:
>>>>
>>>> b.element(tag_name: 'lf-select')
>>>>
>>>> Justin
>>>>
>>>>
>>>> On Tuesday, May 28, 2019 at 1:15:05 AM UTC-4, rajagopalan madasami 
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I have a custom tag named `lf-select`
>>>>>
>>>>> Can't I call in WATIR like
>>>>>
>>>>> b.lf_select()
>>>>>
>>>>> Or something like that? Or Is there anyway?
>>>>>
>>>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/9b6282ec-decf-4f63-902d-8ffa7d07f788%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to call the custom tags?

2019-05-28 Thread Justin Ko
For custom elements, you will need to use the #element method:

b.element(tag_name: 'lf-select')

Justin


On Tuesday, May 28, 2019 at 1:15:05 AM UTC-4, rajagopalan madasami wrote:
>
> Hi,
>
> I have a custom tag named `lf-select`
>
> Can't I call in WATIR like
>
> b.lf_select()
>
> Or something like that? Or Is there anyway?
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/0fa2a316-cbf8-4cfd-bf04-95c7b342f32f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: New warning is showing up now

2019-05-10 Thread Justin Ko
It does not look like Selenium-WebDriver provides a mechanism for ignoring 
specific deprecations. You will have to monkey-patch the error away:

require 'selenium-webdriver'

module Selenium
  module WebDriver
module Error # rubocop:disable Metrics/ModuleLength
  def self.const_missing(const_name)
super unless DEPRECATED_ERRORS.key?(const_name)
if DEPRECATED_ERRORS[const_name]
  
#WebDriver.logger.deprecate("Selenium::WebDriver::Error::#{const_name}",
  #   "#{DEPRECATED_ERRORS[const_name]} 
(ensure the driver supports W3C WebDriver specification)")
  DEPRECATED_ERRORS[const_name]
else
  WebDriver.logger.deprecate(
"Selenium::WebDriver::Error::#{const_name}")
  WebDriverError
end
  end
end
  end
end

Justin



On Friday, May 10, 2019 at 4:16:15 AM UTC-4, rajagopalan madasami wrote:
>
> I meant to ask how can I comment that one?
>
> On Fri, 3 May, 2019, 12:37 AM , > wrote:
>
>> I believe this pull request will address this - 
>> https://github.com/watir/watir/pull/867/files
>>
>> Justin
>>
>> On Thursday, May 2, 2019 at 5:53:55 AM UTC-4, rajagopal...@gmail.com 
>> wrote:
>>>
>>> Hi, 
>>>
>>> I am getting this warning now
>>>
>>> 2019-05-02 13:57:16 WARN Selenium [DEPRECATION] Selenium::WebDriver::
>>> Error::ObsoleteElementError is deprecated. Use Selenium::WebDriver::
>>> Error::StaleElementReferenceError (ensure the driver supports W3C 
>>> WebDriver specification) instead.
>>>
>>>
>>>
>>> -- 
>> -- 
>> 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.
>>  
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-...@googlegroups.com 
>> --- 
>> 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 watir-...@googlegroups.com .
>> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/ef307e86-939c-4c2e-abe4-ee131ade7642%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-16 Thread Justin Ko
Hi Navi,

1) It would depend on who is calling the method - ie a Watir::Element vs a 
PageObject::Element. Generally you would be working with 
PageObject::Element, so you would be calling the Page-Object version. The 
recent versions of Page-Object forward missing methods directly to the 
Watir browser/element, which has clouded things a bit. For finding elements 
you can technically call Watir methods directly, which returns 
Watir::Elements, which means you would get Watir's version of the method. 
If you want to double-check which version is being called, check the class 
of your caller.

2) Calling `element.exists?` will not do any waiting - neither Watir or 
Page-Object's timeouts will apply. The default_element_wait will only apply 
if you did page-object's #check_exists (returns true as soon as the element 
exists, otherwise returns false when the timeout has elapsed).

Justin


On Tuesday, April 16, 2019 at 1:05:27 AM UTC-4, NaviHan wrote:
>
> Hi Justin
>
> I  have two questions here..
>
> 1. 
> Im use *wait_until(&:present) *a lot.
>
> I see *wait_until* is a method which is present in Watir and PageObject 
> and as you said *wait_until of PageObject *depends on 
> *default_element_wait*
>
> Do you know which method is invoked when I call a *wait_until(&:present) *the 
> Watir one or PageObject one?
>
> I have commented out *default_element_wait *in hooks. The nightly suite 
> hasnt run yet. So not sure about the impact.
>
> # PageObject.default_element_wait=(10)
>
>
> So if the PageObject one is invoked then lots of tests will fail
> 2.
>
> If I check for an elements existence like
> *element.exists? *
> As watir doesnt wait here do you suggest leaving default_element_wait to 
> say 30 seconds?
>
> Cheers
> Navi
>
>
> On Monday, 15 April 2019 09:29:57 UTC+10, NaviHan wrote:
>>
>> The automation code in our project uses PageObject and yesterday's 
>> nightly build shows a failure.
>>
>>  [31m  timed out after 10 seconds, waiting for true condition on 
>> #"slide-dialog-container-cart-page", 
>> :tag_name=>"div"}> (Watir::Wait::TimeoutError) [0m
>>
>>
>> On checking hooks I found a statement
>>
>> PageObject.default_element_wait=(10)
>>
>>
>> As per my undersatnding Watir has its own inbuilt page and element level 
>> waits which is a default of 30 seconds?
>> And the above statement over rides that to 10 seconds?
>>
>> Please correct me if Im wrong.
>>
>> Cheers
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: What is the default element and page wait in Watir. Do we have to explicitly set PageObject.default_element_wait?

2019-04-15 Thread Justin Ko
Page-Object introduces its own couple of waits 
(https://github.com/cheezy/page-object/blob/master/lib/page-object.rb#L87-L113):

   - default_page_wait which has a default of 30 and
   - default_element_wait which has a default of 5

The default_element_wait will impact the Element methods #check_exists, 
#check_visible, #when_present, #when_not_present and #wait_until. Also 
impacts some of accessors for waiting for a page to load.

Setting Page-Object's default_element_wait only sometimes overrides Watir's 
in-built waiting. For example:

   - Watir does not do any waiting before checking if an element exists, 
   where as Page-Object's #check_exists wraps the call in a wait (using 
   default_element_wait).
   - In most cases, using #when_present will be overriding - eg 
   element.when_present.click. Page-Object's #when_present wait effectively 
   takes precedence over Watir's in-built one. That said, I would argue you 
   should be removing the #when_present calls (they are a relic from before 
   Watir had the in-built waiting).

Unfortunately not a black-and-white answer. Though again more evidence that 
we need to re-visit what Page-Object is doing given how much Watir has 
evolved.

Justin


On Sunday, April 14, 2019 at 7:29:57 PM UTC-4, NaviHan wrote:
>
> The automation code in our project uses PageObject and yesterday's nightly 
> build shows a failure.
>
>  [31m  timed out after 10 seconds, waiting for true condition on 
> #"slide-dialog-container-cart-page", 
> :tag_name=>"div"}> (Watir::Wait::TimeoutError) [0m
>
>
> On checking hooks I found a statement
>
> PageObject.default_element_wait=(10)
>
>
> As per my undersatnding Watir has its own inbuilt page and element level 
> waits which is a default of 30 seconds?
> And the above statement over rides that to 10 seconds?
>
> Please correct me if Im wrong.
>
> Cheers
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Cant capture alert using "alert" method of Page Object

2019-04-11 Thread Justin Ko
Hi Navi,

At this point, I would say there is a design flaw in Page-Object's #alert 
method, which does:

if @browser.alert.exists?
  value = @browser.alert.text
  @browser.alert.ok
end

The conditional check is likely the cause of your problem. I don't know the 
history of how we got here, but my guess is that we wanted to handle 
controls that randomly created alerts.

Unfortunately, this can be easily thrown off. I assume your div does not 
immediately trigger the alert. There is probably some sort of processing 
and/or asynchronous call that happens before deciding to show the alert. 
This can be enough to cause problems - ie:
# Div is clicked
# Some JavaScript starts to determine if the alert should appear
# #alert checks if an alert exists or not, finds nothing so just moves on 
(ie no alert to dismiss)
# The JavaScript finishes processing, displaying the alert
# The next Watir command fails since the alert is still there

You can see how little is required to create the timing issue. The 
following page has a div, that when clicked waits 10ms before displaying 
the alert.




  
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function run() {
  await sleep(10); // (in milliseconds) slight delay before alert is 
triggered
  alert("test");
}
  


  asdf



The following page-object clicks this div but does not dismiss the alert. 
The exception then occurs on the next command:

class MyPage
  include PageObject

  def do_stuff
alert do
  div.click
end
sleep(1) # ensure alert has appeared
p div.text
#=> Selenium::WebDriver::Error::UnhandledAlertError
  end
end

page = MyPage.new(browser)
page.do_stuff

I would be curious if you added a #sleep to your code if that would address 
the problem:

@browser.div(:class => 'address-details', :index =>0).click
alert_text = alert do
  @browser.div(:class => 'select-checkbox', :index =>1).click
  sleep(10) # add this sleep to ensure that the alert appears before 
proceeding
end
sleep(10)
puts alert_text

Though if that solves your problem, I do not think the #alert method is 
adding any value. You know the alert is going to appear, so you may as well 
call Watir's alert code (ie Titus' example), which would include automatic 
waiting.

Justin


On Thursday, April 11, 2019 at 12:46:32 AM UTC-4, NaviHan wrote:
>
> Hi Titus
>
> @browser.div(:class => 'address-details', :index =>0).click
> # alert_text = alert do
> #   @browser.div(:class => 'select-checkbox', :index =>1).click
> # end
> # sleep 10
> # puts alert_text
> @browser.div(:class => 'select-checkbox', :index =>1).click
> puts @browser.alert.text
> @browser.alert.ok
>
>
> This worked.
>
> But I would like to know why the PageObject method alert is not working as 
> expected.
>
> May be wait for Justin :-)
>
> On Thursday, 11 April 2019 12:23:16 UTC+10, NaviHan wrote:
>>
>> Im trying to capture the alert text and dismiss the alert using the 
>> "alert" method
>>
>>   def test
>> @browser.div(:class => 'address-details', :index =>0).click
>> alert_text = alert do
>>   @browser.div(:class => 'select-checkbox', :index =>1).click
>> end
>> sleep 10
>> puts alert_text
>>
>>
>>   end
>>
>>
>> I have passed @browser.div(:class => 'select-checkbox', :index =>1).click  
>> into the alert method which actually triggers the alert
>>
>> As per the implementation this should capture the alert text and click OK
>>
>> However I'm getting this error
>>
>> elenium::WebDriver::Error::UnhandledAlertError: unexpected alert open: 
>> {Alert text : This address cannot be used.}
>>   (Session info: chrome=73.0.3683.86)
>>   (Driver info: chromedriver=2.38.552522 
>> (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 
>> x86_64)
>>
>>
>> A video of the issue here @ 
>> https://drive.google.com/file/d/1Di9idgfqjE7TLSn5QG7pgUFxpln3kben/view?usp=sharing
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to keep the Watir browser run on the backend?

2019-04-10 Thread Justin Ko
The --window-position arguments should be without a space - eg:

args = ['--window-position=-3000,0']
browser = Watir::Browser.new :chrome, options: {args: args}

Note that this is just positioning it off-screen; not actually minimizing.

Justin


On Wednesday, April 10, 2019 at 12:33:41 PM UTC-4, NaviHan wrote:
>
> Tried this, browser didnt minimize
>
>   args = ['--allow-running-insecure-content --window-position=-3000, 0']
>   browser = Watir::Browser.new :chrome, options: {args: args}
>
> Titus is this correct?
> On Wednesday, 10 April 2019 22:42:13 UTC+10, watirQ wrote:
>>
>> Experts 
>>
>> Each time when use .goto or open a new tab, the browser window will lump 
>> to the frontend of the screen. How to keep the Watir browser run on the 
>> backend, so that will  not interrupt other works
>>
>> Thanks
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble undersatnding "Around" hook

2019-04-04 Thread Justin Ko
Sorry Navi, I'm not too familiar with the inner workings of Cucumber. I 
abandoned it long ago for RSpec. While people on this mailing list can 
likely help with how to use Cucumber, understanding the internal workings 
is likely better suited in Cucumber's mailing list (or whatever they use).

For what I can see, if you want to understand how the Around works, you can 
start following the code from 
https://github.com/cucumber/cucumber-ruby/blob/558a89faf615c2e9be674b17061934243cd19d50/lib/cucumber/glue/dsl.rb#L75-L82.

I haven't heard of people complaining about hook orders fluctuating. It 
would seem pretty useless if their order wasn't consistent. Do you have 
specific article that says that? 

Justin


On Wednesday, April 3, 2019 at 7:39:35 PM UTC-4, NaviHan wrote:
>
> Hi Titus/Justin
>
> If you could help me here understanding this...
>
> Also what is the order in which the before, after and around hooks run.
>
> I tried printing the order and as per my experimenatation the order is
>
> 1. Around
> 2. Before &
> 3. After
>
> Some of the articles I read says this order is fluctuating.. Is this true?
>
> On Friday, 29 March 2019 16:33:14 UTC+11, NaviHan wrote:
>>
>> Im trying to understand how the around hooks work
>>
>> Im sorry if the question is very basic. I cant find the implementation of 
>> "Around" in Cucumber API docs as well (checked  
>>
>> *Cucumber::RbSupport::RbDsl*
>> in
>>
>> *Around **do *|*scenario*, *block*|
>>
>>   puts *"About to run *#{*scenario*.name}
>>
>> *"  **block*.call
>>
>>   puts *"Finished running *#{*scenario*.name}
>>
>> *"**end*
>>
>>
>> I was expecting scenario.call instead of block.call
>>
>> How does the scenario gets passed to block?
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: Action Builder

2019-04-04 Thread Justin Ko
Do you know what library is being used to create that select list?

Justin

On Wednesday, April 3, 2019 at 12:25:43 PM UTC-4, rajagopalan madasami 
wrote:
>
> Hi Justin, 
>
> Thanks. I am aware of click with modifiers uses action builder under the 
> hood. My requirement is, I am automating a new application in which to 
> choose the option, I need to click the select list and the option would 
> appear like any other select list and the I have to click the option . This 
> is the way selection can be performed . The problem here is I can use WATIR 
> click for select list but then when I click the option using WATIT/SELENIUM 
> click its not choosing the option but If I click that option using action 
> builder then it's choosing the option. Do you have any idea why this 
> happens? And also how does this action builder click differ from selenium 
> click?
>
> On Wed, 3 Apr, 2019, 9:45 PM Justin Ko, > 
> wrote:
>
>> There is nothing directly provided for working with the ActionBuilder. If 
>> you need to call the ActionBuilder, you will need to access the 
>> Selenium::WebDriver and convert the Watir::Element using #wd - eg:
>>
>> browser.driver.action.click(your_watir_element.wd).perform
>>
>> Note that there are methods that use the ActionBuilder under the covers - 
>> eg #click with modifiers. Ideally we'd write methods for things that need 
>> the ActionBuilder (ie no need to call it directly), so let us know if there 
>> are common methods you need.
>>
>> Justin
>>
>>
>> On Wednesday, April 3, 2019 at 2:29:07 AM UTC-4, rajagopal...@gmail.com 
>> wrote:
>>>
>>> hi, Is there any WATIR module is defined to use ActionBuilder. For an 
>>> example, How can I do the following code in WATIR?
>>>
>>> driver.action.click(element).perform
>>>
>>> Any WATIR way of performing the above operation?
>>>
>>> -- 
>> -- 
>> 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.
>>  
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-...@googlegroups.com 
>> --- 
>> 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 watir-...@googlegroups.com .
>> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Action Builder

2019-04-03 Thread Justin Ko
There is nothing directly provided for working with the ActionBuilder. If 
you need to call the ActionBuilder, you will need to access the 
Selenium::WebDriver and convert the Watir::Element using #wd - eg:

browser.driver.action.click(your_watir_element.wd).perform

Note that there are methods that use the ActionBuilder under the covers - 
eg #click with modifiers. Ideally we'd write methods for things that need 
the ActionBuilder (ie no need to call it directly), so let us know if there 
are common methods you need.

Justin


On Wednesday, April 3, 2019 at 2:29:07 AM UTC-4, rajagopal...@gmail.com 
wrote:
>
> hi, Is there any WATIR module is defined to use ActionBuilder. For an 
> example, How can I do the following code in WATIR?
>
> driver.action.click(element).perform
>
> Any WATIR way of performing the above operation?
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to check if a collection is present in PageObject?

2019-03-27 Thread Justin Ko
If there are no matching elements, you should get an empty Array:

p page.products_on_wishlist_elements.class
#=> Array
p page.products_on_wishlist_elements
#=> []

Justin


On Wednesday, March 27, 2019 at 8:18:45 AM UTC-4, NaviHan wrote:
>
> Hi Titus
>
> I read a wondeful article about the enumerable methods, Any, All, None & 
> One.
>
> https://www.rubyguides.com/2018/10/any-all-none-one/
>
> For the particular example in the first post, I used the below code to 
> just return if wishlist is empty(No buttons are present on the wishlist 
> page) and this works.
>
> return if !products_on_wishlist_elements.any?
>
> My doubt is 
>
> When you define the elements as buttons(:products_on_wishlist, :class => 
> 'product-quick-add') and there are no buttons on wishlist page, is the 
> collection array set to empty or nil ?
>
> Because 
> [nil].any?  
>
> also returns false
>
> Cheers
> NaviHan
>
> On Wednesday, 27 March 2019 11:08:54 UTC+11, NaviHan wrote:
>>
>> Hi 
>>
>> I have a collections of buttons defined as  is the element 
>>
>  
>
>>
>> buttons(:products_on_wishlist, :class => 'product-quick-add')
>>
>>
>>
>> Basically they represent the products on wishlist 
>>
>> The page can have
>> 1. No products (no buttons)
>> 2. One product (1 button)
>> 3. More than one products (more than 1 button)
>>
>> I need to check if the wishlist page is empty. Basically I want to check 
>> if the button is present on not.
>> Because the button is defined as a collection
>>
>>
>> products_on_wishlist_elemets.present? 
>>
>>
>> is not working.
>>
>> Is there a way to check if the collection is present or not?
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread Justin Ko
Generally, no, there is no easier way to deal with nested elements. Though 
if you don't need to access :wishlist_remove_all, you could just do:

span(:remove_all_link){ div(class: "wishlist-removal-all").span }

I don't think Page-Object is making it any harder than pure Watir.

Page-Object does provide some "convenience" for elements in frames, which 
we could extend to other elements:

iframe(id: 'frame_id') do |iframe|
  span(:something, class: 'class', frame: iframe)
end

Justin


On Tuesday, March 26, 2019 at 3:05:55 PM UTC-4, Titus Fortner wrote:
>
> The other reason to perhaps prefer css is that Page Object gem makes using 
> nested elements harder.
>
> span(:remove_all_link, :css=> ".wishlist-remove-all span")
> I think would need to look like:
>
> element(:wishlist_remove_all, :class => "wishlist-remove-all") 
> span(:remove_all_link){ wishlist_remove_all_element.span } 
>
> Justin is there an easier way to do this in PO gem?
>
>
>
>
>
> On Tuesday, March 26, 2019 at 11:39:39 AM UTC-5, Justin Ko wrote:
>>
>> In most cases, it is simply a matter of personal preference. There is 
>> usually no technical difference between between using CSS/XPath vs 
>> attributes. To me, the most important thing is to be consistent as an 
>> organization so that code is consistent, which makes the code easier to 
>> read/maintain. I would push using attributes as easier to read and less 
>> error prone. However, I have worked with people coming from Capybara that 
>> feel that CSS expressions are easier to read/use.
>>
>> That said, there is one place where using CSS/XPath is the better 
>> solution - creating a collection of nested elements without the same 
>> ancestors.
>>
>> For example, let's say you have the following HTML:
>>
>>
>> 
>>   
>> link A
>>   
>>   
>> link B
>>   
>> 
>>
>> Your current accessor, will match *2* links:
>>
>> links(:product_names, :css => ".price-and-quick-add-button-wrapper 
>> a.name-link")
>>
>> Unlike the CSS-locator, nesting Watir's element calls only looks in the 
>> first matching element. Therefore, you would only get *1* match if you 
>> tried:
>>
>> links(:product_names) { div(class: "price-and-quick-add-button-wrapper").
>> links(class: "name-link") }
>>
>> To get the *2* links without CSS/XPath you would need to make some ugly 
>> iteration of elements, which is harder to read/write and worse with more 
>> levels of nesting:
>>
>> links(:product_names) { divs(class: "price-and-quick-add-button-wrapper"
>> ).map { |div| div.links(class: "name-link") }.flatten }
>>
>> Of course, this assumes you're stuck with the HTML you have. The better 
>> answer would be to add more attributes so that you can locate the links 
>> directly (ie not deal with nesting).
>>
>> - Justin
>>
>>
>> On Tuesday, March 26, 2019 at 5:19:06 AM UTC-4, NaviHan wrote:
>>>
>>> Hi Titus
>>>
>>> Today I saw a team member defining elements like this
>>>
>>> +  a(:start_shopping_link, :css => "a.start-shopping")
>>>
>>>
>>> <https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#add-comment>
>>>  
>>> <https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#Lcuke-tests/features/support/pages/Frontend/Cotton_On/Wishlist_Page.rbT12>
>>>
>>> +  links(:product_names, :css => ".price-and-quick-add-button-wrapper 
>>> a.name-link")
>>>
>>>
>>> <https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#add-comment>
>>>  
>>> <https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#Lcuke-tests/features/support/pages/Frontend/Cotton_On/Wishlist_Page.rbT13>
>>>
>>> +  links(:product_thumbnails, :css => "a.thumb-link")
>>>
>>>
>>> <https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#add-comment>
>>>  
>>> <https://bitbucket.org/CottonOnGroupEComm/cog-ui-auto/pull-requests/228/co-3896-automation-wishlist/diff#Lcuke-tests/features/support/pages/Frontend/Cotton_On/Wishlist_Page.rbT14>
>>>
>>> +  span(:remove_all_link, :css=> ".wishlist-remove-all span")
>>>
>&

[wtr-general] Re: Which is better in PageObject model, using id, class, name to identify elements or using css to identify elements

2019-03-26 Thread Justin Ko
In most cases, it is simply a matter of personal preference. There is 
usually no technical difference between between using CSS/XPath vs 
attributes. To me, the most important thing is to be consistent as an 
organization so that code is consistent, which makes the code easier to 
read/maintain. I would push using attributes as easier to read and less 
error prone. However, I have worked with people coming from Capybara that 
feel that CSS expressions are easier to read/use.

That said, there is one place where using CSS/XPath is the better solution 
- creating a collection of nested elements without the same ancestors.

For example, let's say you have the following HTML:



  
link A
  
  
link B
  


Your current accessor, will match *2* links:

links(:product_names, :css => ".price-and-quick-add-button-wrapper 
a.name-link")

Unlike the CSS-locator, nesting Watir's element calls only looks in the 
first matching element. Therefore, you would only get *1* match if you 
tried:

links(:product_names) { div(class: "price-and-quick-add-button-wrapper").
links(class: "name-link") }

To get the *2* links without CSS/XPath you would need to make some ugly 
iteration of elements, which is harder to read/write and worse with more 
levels of nesting:

links(:product_names) { divs(class: "price-and-quick-add-button-wrapper").map 
{ |div| div.links(class: "name-link") }.flatten }

Of course, this assumes you're stuck with the HTML you have. The better 
answer would be to add more attributes so that you can locate the links 
directly (ie not deal with nesting).

- Justin


On Tuesday, March 26, 2019 at 5:19:06 AM UTC-4, NaviHan wrote:
>
> Hi Titus
>
> Today I saw a team member defining elements like this
>
> +  a(:start_shopping_link, :css => "a.start-shopping")
>
>
> 
>  
> 
>
> +  links(:product_names, :css => ".price-and-quick-add-button-wrapper 
> a.name-link")
>
>
> 
>  
> 
>
> +  links(:product_thumbnails, :css => "a.thumb-link")
>
>
> 
>  
> 
>
> +  span(:remove_all_link, :css=> ".wishlist-remove-all span")
>
>
> Heavy use of css.
> I cant tell them why they should use css :-)
>
> Could you please let me know the disadvantage here?
>
> On Sunday, 24 March 2019 17:15:53 UTC+11, NaviHan wrote:
>>
>> I have seen in my project using css to identify elements using PageObject.
>> I always use attributes like id, class and name to identify elements.
>>
>> Which is the better way and why?
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Is there an autogenerated method in page-object that tell if the element is present?

2019-02-02 Thread Justin Ko
Hi,

1. The monkey patch is redefining the method. Last definition wins. It is 
how Ruby is designed, nothing specific to Page-Object. A simpler isolated 
example:

def a
  'hi'
end


def a
  'bye'
end


puts a
#=> "bye"

Notice that you can define the method twice, but when called, the last 
definition wins.


2. This is a scenario where you will want to use the widget feature 
(https://github.com/cheezy/page-object/wiki/Custom-page-object-elements-by-using-widgets).
 
The code would be:

# A class to represent your control (ie div that acts like a button)
class DivButton < PageObject::Elements::Div
  def self.accessor_methods(accessor, name)
# Adds method to perform click
accessor.send(:define_method, "#{name}") do
  self.send("#{name}_element").click
end
  end
end
PageObject.register_widget :div_button, DivButton, :div


class MyPage
  include PageObject
 
  # Use div_button instead of div to use your widget
  div_button(:expand_perks_section_icon, :css => '.icon-plus-wrapper')
end


page = MyPage.new(browser)
page.expand_perks_section_icon #=> triggers click on div
page.expand_perks_section_icon? #=> has standard method to check element 
existence (or presence with the monkey patch)


Hope that helps,
Justin


On Friday, February 1, 2019 at 6:17:10 PM UTC-5, NaviHan wrote:
>
> Thanks Justin..
> I have two more question though.
>
> 1. How does the the method in monkey_path.b takes precedence over the 
> method in actual page-object gem?
> 2. There are may intances in the application where a div element receives 
> the click rather than a button.
>
> eg
>   div(:expand_perks_section_icon, :css => '.icon-plus-wrapper')
>
>
>
> This element is  a div and receives the click as shown below.
>   def expand_perks_section
> expand_perks_section_icon_element.when_present.click
>   end
>
>
>
> Writing a separate method each time for such things is really a pain.
> Is there a better solution for such cases
>
> On Friday, 1 February 2019 00:11:33 UTC+11, NaviHan wrote:
>>
>> I have an element defined as
>>
>> div(:reward_history, :class => 'reward-history-header')
>>
>>
>> The page-object gem generated four methods for this element which are
>>
>>
>> 'reward_history', 'reward_history_element', and 'reward_history?'
>>
>>
>>
>> The fourth method 'reward_history?' check if the element exists in the 
>> DOM?
>>
>>
>> But what if the element exists in the DOM but is hidden, which is 
>> basically checking if the element is present?
>>
>>
>> Is there an autogenerated method for this?
>>
>> I tried 'reward_history(:?)' but didn't work
>>
>> As of now I have to write a method separately which does this
>>
>>   def is_reward_history_present?
>> return reward_history_element.present?
>>   end
>>
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Is there an autogenerated method in page-object that tell if the element is present?

2019-02-01 Thread Justin Ko
Yes, that would work.

Personally, I find "falsey" hard to type. Technically it also includes 
"nil", though #present? shouldn't return that. I tend to go with:

expect(on(MyAccountPage).reward_history?).to eq false


The monkey patch is redefining the method. It's one of those good and bad 
things that Ruby lets you do.

Justin


On Thursday, January 31, 2019 at 6:18:51 PM UTC-5, NaviHan wrote:
>
> Thanks Justin for creating a feature request.
>
> What I have done is I have created a file name monkeypatch.rb and put the 
> code you have given in there.
> Changed the script to use and it passed.
>
> expect(on(MyAccountPage).reward_history?).to be_falsey
>
> Could you please confirm if this is the right way to do this.
>
> By the way Im confused how the script know it has to give priority to 
> standard_methods in the monkypatch.rb rather in the actual PageObject 
> module?
>
>
> On Friday, 1 February 2019 00:11:33 UTC+11, NaviHan wrote:
>>
>> I have an element defined as
>>
>> div(:reward_history, :class => 'reward-history-header')
>>
>>
>> The page-object gem generated four methods for this element which are
>>
>>
>> 'reward_history', 'reward_history_element', and 'reward_history?'
>>
>>
>>
>> The fourth method 'reward_history?' check if the element exists in the 
>> DOM?
>>
>>
>> But what if the element exists in the DOM but is hidden, which is 
>> basically checking if the element is present?
>>
>>
>> Is there an autogenerated method for this?
>>
>> I tried 'reward_history(:?)' but didn't work
>>
>> As of now I have to write a method separately which does this
>>
>>   def is_reward_history_present?
>> return reward_history_element.present?
>>   end
>>
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Is there an autogenerated method in page-object that tell if the element is present?

2019-01-31 Thread Justin Ko
You are correct that #reward_history? calls #exists?. There is no 
auto-generated method for #present?.

It is rather unfortunate. Checking presence is probably more common than 
checking existence. As a backwards incompatible change, it'll take some 
time to change.

If you want, you could monkey-patch to use #present? instead of #exists?:

module PageObject
  module Accessors
def standard_methods(name, identifier, method, )
  define_method("#{name}_element") do
return call_block() if block_given?
platform.send(method, identifier.clone)
  end
  define_method("#{name}?") do
return call_block().present? if block_given?
platform.send(method, identifier.clone).present?
  end
end
  end
end

I created a feature request 
(https://github.com/cheezy/page-object/issues/476), but like I said before, 
it'd take some time to roll out.

- Justin


On Thursday, January 31, 2019 at 8:11:33 AM UTC-5, NaviHan wrote:
>
> I have an element defined as
>
> div(:reward_history, :class => 'reward-history-header')
>
>
> The page-object gem generated four methods for this element which are
>
>
> 'reward_history', 'reward_history_element', and 'reward_history?'
>
>
>
> The fourth method 'reward_history?' check if the element exists in the 
> DOM?
>
>
> But what if the element exists in the DOM but is hidden, which is 
> basically checking if the element is present?
>
>
> Is there an autogenerated method for this?
>
> I tried 'reward_history(:?)' but didn't work
>
> As of now I have to write a method separately which does this
>
>   def is_reward_history_present?
> return reward_history_element.present?
>   end
>
>
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: b.select_list.select is not working in 6.16

2018-12-21 Thread Justin Ko
Hi Raj,

I think we still need more details on how to reproduce the problem.

I do not see anything obviously wrong from the logs. As well, given the 
page:


  Any
  Mr


Selection is working:

@b.select_list(id: "salutation").select 'Mr'
p @b.select_list(id: "salutation").selected_options.map(&:text)
#=> ["Mr"]

It would help if you can create an isolated example that reproduces the 
issue.

Thanks,
Justin


On Thursday, December 20, 2018 at 11:52:23 PM UTC-5, rajagopalan madasami 
wrote:
>
> Hi Titus, I have given the details in my last mail. Can you look into that 
> ?
>
> On Wed 19 Dec, 2018, 9:43 PM Titus Fortner   wrote:
>
>> Our specs are all passing, so you need to provide a reproducible issue
>> so we can add the use case to our test suite.
>>
>> On Wed, Dec 19, 2018 at 8:50 AM Justin Ko > > wrote:
>> >
>> > Can you elaborate on what is not working?
>> >
>> > I get the same behaviour in 6.14 and 6.16 when running the below script 
>> - ie `browser.select_list.select` does not select anything.
>> >
>> > gem 'watir', '=6.14'
>> > require 'watir'
>> >
>> > browser = Watir::Browser.new
>> > browser.goto 'test_page.html'
>> >
>> > browser.select_list.select('b')
>> > p browser.select_list.selected_options.map(&:text)
>> > #=> ["b"]
>> >
>> > browser.select_list.select
>> > p browser.select_list.selected_options.map(&:text)
>> > #=> ["b"]
>> >
>> > Thanks,
>> > Justin
>> >
>> >
>> > On Wednesday, December 19, 2018 at 5:45:43 AM UTC-5, 
>> rajagopal...@gmail.com wrote:
>> >>
>> >> hi Titus,
>> >>
>> >> b.select_list().select is not working in 6.16 but it's working 6.14.
>> >>
>> >> So I have written
>> >>
>> >> `b.select_list().option.select` and it's working fine. So it's a clear 
>> bug in WATIR 6.16
>> >
>> > --
>> > --
>> > 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.
>> >
>> > watir-...@googlegroups.com 
>> > http://groups.google.com/group/watir-general
>> > watir-genera...@googlegroups.com 
>> > ---
>> > 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 watir-genera...@googlegroups.com .
>> > 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.
>>
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com 
>> --- 
>> 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 watir-genera...@googlegroups.com .
>> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: b.select_list.select is not working in 6.16

2018-12-19 Thread Justin Ko
Can you elaborate on what is not working?

I get the same behaviour in 6.14 and 6.16 when running the below script - 
ie `browser.select_list.select` does not select anything.

gem 'watir', '=6.14'
require 'watir'

browser = Watir::Browser.new
browser.goto 'test_page.html'

browser.select_list.select('b')
p browser.select_list.selected_options.map(&:text)
#=> ["b"]

browser.select_list.select
p browser.select_list.selected_options.map(&:text)
#=> ["b"]

Thanks,
Justin


On Wednesday, December 19, 2018 at 5:45:43 AM UTC-5, rajagopal...@gmail.com 
wrote:
>
> hi Titus,
>
> b.select_list().select is not working in 6.16 but it's working 6.14. 
>
> So I have written 
>
> `b.select_list().option.select` and it's working fine. So it's a clear bug 
> in WATIR 6.16
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Issue with watir index or Am I doing something wrong

2018-11-24 Thread Justin Ko
Hi Navi,

One element still counts as a collection, so it should work. What error did 
you get?

Justin


On Saturday, November 24, 2018 at 12:52:22 AM UTC-5, NaviHan wrote:
>
> Hi Justin
>
> The collection was the first thing I tried. But the issue is when there is 
> only one gift card applied, meaning only one div with class  then applied_gift_card_elements[0] gave me error.
>
> Will the collection work when there is just one div?
>
> On Friday, 23 November 2018 13:06:07 UTC+11, NaviHan wrote:
>>
>> Having trouble using index.
>>
>> I have a section of a page as below.
>> 
>> 
>> Card
>> Amount Taken
>> 
>> > style="display: flex;">
>> ...163867647149
>> $20.00
>> 
>> > data-gcid="2790030163867647149">
>> > >
>> 
>> 
>> 
>> 
>> > style="display: flex;">
>> ...169169063156
>> $25.90
>> 
>> ($74.10 left on card)
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>
>>
>> The pageobject is defined as
>>
>> div(:applied_gift_cards, :class => 'gc-list')
>>
>>
>>
>>
>> And Im trying to access "...163867647149 " and "$20.00" as which gave 
>> error
>>
>> return applied_gift_cards_element.div_element(:index => 
>> 1).div_element(:index =>0).text
>>
>> return applied_gift_cards_element.div_element(:index => 
>> 1).div_element(:index =>0).text
>>
>> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
>> waiting for #"gc-list", 
>> :tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0, 
>> :tag_name=>"div"}> to be located
>>
>> When printing the same element actually prints the Pageobect
>> puts applied_gift_cards_element.div_element(:index => 1).div_element(:index 
>> =>0)
>> #
>>
>>
>> A puts of the following printed as below which is again confusing
>>
>> puts applied_gift_cards_element.div_element(:index => 0).inner_html
>> puts applied_gift_cards_element.div_element(:index => 1).inner_html
>> puts applied_gift_cards_element.div_element(:index => 2).inner_html
>> puts applied_gift_cards_element.div_element(:index => 3).inner_html
>>
>> Card
>>  Amount Taken
>> Card
>> Amount Taken
>> ...163867647149$20.00> type="button" class="remove-gift-cert pointer" 
>> data-gcid="2790030163867647149">
>>
>>
>>
>>
>> Am I doing something wrong here?
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Issue with watir index or Am I doing something wrong

2018-11-23 Thread Justin Ko
Instead of working from the the "gc-list", you could work from the 
"gift-cards-list". It would save a level of nesting and eliminate the child 
vs descendant difference:

# Page-Object
divs(:applied_gift_card, :class => 'gift-cards-list')

# Usage
p page.applied_gift_card_elements[0].div_element(index: 0).text
#=> "...163867647149"
p page.applied_gift_card_elements[0].div_element(index: 1).text
#=> "$20.00"

For readability, I would suggest taking it a step further and using page 
sections:

class MyPage
  include PageObject

  class AppliedGiftCard
include PageObject

div(:card, index: 0)
div(:amount_taken, index: 1)
  end

  page_sections(:applied_gift_cards, AppliedGiftCard, class: 
'gift-cards-list', tag_name: 'div')
end

page = MyPage.new(browser)
p page.applied_gift_cards[0].card
#=> "...163867647149"
p page.applied_gift_cards[0].amount_taken
#=> "$20.00"
p page.applied_gift_cards[1].card
#=> "...169169063156"
p page.applied_gift_cards[1].amount_taken
#=> "$25.90\n($74.10 left on card)"

Justin


On Thursday, November 22, 2018 at 11:44:34 PM UTC-5, NaviHan wrote:
>
> Oops my understanding was wrong here :-(
>
> I can achieve this by using 
>
> return applied_gift_cards_element.children[index.to_i].children[0].text
>
> Is there a a better way?
>
>
> On Friday, 23 November 2018 13:06:07 UTC+11, NaviHan wrote:
>>
>> Having trouble using index.
>>
>> I have a section of a page as below.
>> 
>> 
>> Card
>> Amount Taken
>> 
>> > style="display: flex;">
>> ...163867647149
>> $20.00
>> 
>> > data-gcid="2790030163867647149">
>> > >
>> 
>> 
>> 
>> 
>> > style="display: flex;">
>> ...169169063156
>> $25.90
>> 
>> ($74.10 left on card)
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>
>>
>> The pageobject is defined as
>>
>> div(:applied_gift_cards, :class => 'gc-list')
>>
>>
>>
>>
>> And Im trying to access "...163867647149 " and "$20.00" as which gave 
>> error
>>
>> return applied_gift_cards_element.div_element(:index => 
>> 1).div_element(:index =>0).text
>>
>> return applied_gift_cards_element.div_element(:index => 
>> 1).div_element(:index =>0).text
>>
>> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
>> waiting for #"gc-list", 
>> :tag_name=>"div"} --> {:index=>1, :tag_name=>"div"} --> {:index=>0, 
>> :tag_name=>"div"}> to be located
>>
>> When printing the same element actually prints the Pageobect
>> puts applied_gift_cards_element.div_element(:index => 1).div_element(:index 
>> =>0)
>> #
>>
>>
>> A puts of the following printed as below which is again confusing
>>
>> puts applied_gift_cards_element.div_element(:index => 0).inner_html
>> puts applied_gift_cards_element.div_element(:index => 1).inner_html
>> puts applied_gift_cards_element.div_element(:index => 2).inner_html
>> puts applied_gift_cards_element.div_element(:index => 3).inner_html
>>
>> Card
>>  Amount Taken
>> Card
>> Amount Taken
>> ...163867647149$20.00> type="button" class="remove-gift-cert pointer" 
>> data-gcid="2790030163867647149">
>>
>>
>>
>>
>> Am I doing something wrong here?
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: problem when locating the element

2018-11-06 Thread Justin Ko
Any chance you can capture a video of the test? It's hard to reconcile this 
discussion and logs without seeing anything.

Justin

On Tuesday, November 6, 2018 at 12:37:01 PM UTC-5, rajagopalan madasami 
wrote:
>
> I am calling this function 
>
> def waitForPageLoad
>
>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
> (jQuery.active === 0)").eql? true}
> end
>
> function in every click function like
>
> def clickButton(locator, action, name, data)
>   puts "ClickButton   : #{name}"
>   loc = getLocator(locator)
>   @b.button(loc.first => loc.last).click
>   waitForPageLoad
> end
>
> Do you see the clickButton method 
>
> calls waitForPageLoad at the end so it waits for the spinner disappear. So it 
> doesn't click on the spinner. Even if it clicks at the 
>
> spinner it retry it because I have included 
> Selenium::WebDriver::Error::ElementClickInterceptedError
>
> rescue Selenium::WebDriver::Error::ElementNotVisibleError, 
> Selenium::WebDriver::Error::ElementNotInteractableError,Selenium::WebDriver::Error::ElementClickInterceptedError
>   raise_present unless Wait.timer.remaining_time.positive?
>   raise_present unless %i[wait_for_present wait_for_enabled 
> wait_for_writable].include?(precondition)
>   retry
>
> So all I am seeing here is, It perfectlys lands on a page, and it 
> successfully enters into the click method but it waits for 30 seconds and it 
> fails. 
>
>   
>
>
> On Tue, 6 Nov 2018 at 22:51, Titus Fortner  > wrote:
>
>> Yes, this makes sense from the code perspective.
>>
>> What your site is doing is requiring you to accept an alert, then it
>> does some kind of processing, then it refreshes some/all of the page.
>>
>> Your code is trying to click the element before the refresh has
>> happened, and because of the way you are rescuing it, it is giving you
>> misleading information. The element was located but couldn't be used,
>> then at the point it is trying to be used it is stale, and that method
>> isn't relocating when stale.
>>
>> Can you raise an issue on Github with this gist? Something like "Watir
>> should relocate stale elements when trying to click them"
>>
>> In the meantime, something like this should work:
>>
>> @b.alert.ok
>> @b.div(id: "spinnerOverlay").wait_while(&:present?)
>> @b.button(id: "NavContinue").click
>>
>>
>> On Tue, Nov 6, 2018 at 10:56 AM > 
>> wrote:
>> >
>> > Hi Titus,
>> >
>> > Here is the gist url
>> >
>> > https://gist.github.com/Rajagopalan-M/ba78aed6342c61d07968cfe195d3f4de
>> >
>> > --
>> > --
>> > 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.
>> >
>> > watir-...@googlegroups.com 
>> > http://groups.google.com/group/watir-general
>> > watir-genera...@googlegroups.com 
>> > ---
>> > 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 watir-genera...@googlegroups.com .
>> > 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.
>>
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com 
>> --- 
>> 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 watir-genera...@googlegroups.com .
>> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: problem when locating the element

2018-11-06 Thread Justin Ko
>From the logs, I see:

   1. A "Checking this box will delete any prior coverages" alert is 
   accepted
   2. The NavContinue button is retrieved (elementID: 
   04743404-40e9-4dc0-bae8-1f3e270f3eae)
   3. Several clicks are attempted, but intercepted by 
   4. Several clicks are attempted, but raise stale reference errors
   
What does the application do when accepting the alert (Step 1)? Does it 
cause the overlay to be displayed and then a page refresh?

Justin


On Tuesday, November 6, 2018 at 11:56:57 AM UTC-5, rajagopal...@gmail.com 
wrote:
>
> Hi Titus,
>
> Here is the gist url
>
> https://gist.github.com/Rajagopalan-M/ba78aed6342c61d07968cfe195d3f4de
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to handle behavior while pop up loads, is sleep is the only solution?

2018-10-02 Thread Justin Ko
Hi Navi,

I would expect the closing situation to be much simpler. You should be able 
to just check that the element is no longer present:

slide_dialog = browser.div(id: 'slide-dialog-container')
slide_dialog.wait_while(&:present?)

The overflow was only important in the expanding case as it meant that 
elements could be moving around the page. For closing/collapsing, once the 
popup is gone there should be nothing changing on the page.

Justin


On Tuesday, October 2, 2018 at 2:38:32 AM UTC-4, NaviHan wrote:
>
> Hi Justin
>
> This works fine and I have ran the script multiple times and it passed. 
> This is configured to run on Jenkins Boxes. Waiting for overnight results.
> As a related question.
>
> We use the below code for the pop up to load completely. I have a 
> verification to be done after the pop up has completely disappeared.
>
> I know we need to do wait_while but how do we combine s.present? && s.
> style('overflow') == 'visible' to evaluate to false ?
>
> Cheers
>
>
>
> On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>>
>> Its been some days I found this issue untill I understood today the cause 
>> of failure.
>>
>> The behavior is
>> a. The user enters the email on check out page
>> b. A pop up skids in from the top of the page
>> c. The user clicks a "continue as guest "button on the pop up
>> d. The pop up skids back in and disappears
>> e. Verify the pop up disappeared
>>
>> The issue is between step b and step c there is a time when the pop up is 
>> sliding into the page until its loaded completely. During this time the 
>> script clicks the dismiss button. Because the pop hasent completed loading 
>> the click doesn't make it disappear.
>>
>> Similarly becasue the pop up takes time to slide back and disapper the 
>> check at step e fails.
>>
>> For the time being Im working around this issue with sleeps. But is there 
>> a neater way?
>>
>>
>> The pop up is defined as 
>>
>> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>>
>>
>> The code that does the job is 
>>
>> def continue_as_guest
>>   continue_as_guest_element.wait_until(&:present?).click
>> end
>>
>>
>> After sleep, which works fine
>>
>> def continue_as_guest
>>   sleep 5
>>   continue_as_guest_element.wait_until(&:present?).click
>>   sleep 5
>> end
>>
>>
>> Note:- I have also tried to wait_while(&:present?) still the issue stays 
>> the same
>>
>> def continue_as_guest
>>   
>> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
>> end
>>
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-26 Thread Justin Ko
Navi,

In the video of the problem, you can actually see the overflow style change 
while the section is sliding.

You can also see it change using the following Watir code:

browser.link(text: 'Sign in here').click
slide_dialog = browser.div(id: 'slide-dialog-container')

150.times { puts slide_dialog.style('overflow') }
#=> "visible"
#=> ...
#=> "visible"
#=> "hidden"
#=> ...
#=> "hidden"
#=> "visible"
#=> ...
#=> "visible"

Note that when there is no animation, the overflow isn't set. As a result, 
you get the default "visible" even when the section is hidden (ie at the 
start of the above output). This is why I paired the #present? check. If 
you want to save a bit of performance, you really want to check that the 
sliding dialog is present and then wait on the style.

Justin


On Wednesday, September 26, 2018 at 4:31:21 AM UTC-4, NaviHan wrote:
>
> Hi Justin/Titus
>
> Trying to understand the overflow attribute in style sheet
>
> When the pop up is not present the oveflow property is there unser style 
> as shown here
> https://i.imgur.com/X1MxiHD.png
>
> When the popup is fully loaded its the same.
>
> https://i.imgur.com/xu5E3mp.png
>
> So what does this mean, s.style('overflow') == 'visible', and where can 
> we verify that 
>
>
>
>
> On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>>
>> Its been some days I found this issue untill I understood today the cause 
>> of failure.
>>
>> The behavior is
>> a. The user enters the email on check out page
>> b. A pop up skids in from the top of the page
>> c. The user clicks a "continue as guest "button on the pop up
>> d. The pop up skids back in and disappears
>> e. Verify the pop up disappeared
>>
>> The issue is between step b and step c there is a time when the pop up is 
>> sliding into the page until its loaded completely. During this time the 
>> script clicks the dismiss button. Because the pop hasent completed loading 
>> the click doesn't make it disappear.
>>
>> Similarly becasue the pop up takes time to slide back and disapper the 
>> check at step e fails.
>>
>> For the time being Im working around this issue with sleeps. But is there 
>> a neater way?
>>
>>
>> The pop up is defined as 
>>
>> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>>
>>
>> The code that does the job is 
>>
>> def continue_as_guest
>>   continue_as_guest_element.wait_until(&:present?).click
>> end
>>
>>
>> After sleep, which works fine
>>
>> def continue_as_guest
>>   sleep 5
>>   continue_as_guest_element.wait_until(&:present?).click
>>   sleep 5
>> end
>>
>>
>> Note:- I have also tried to wait_while(&:present?) still the issue stays 
>> the same
>>
>> def continue_as_guest
>>   
>> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
>> end
>>
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-25 Thread Justin Ko
Trying this on a faster machine and against some other pages, I'm noticed 
flaws in my previous testing. Some of the properties, ex Element#height, 
start as if the sliding container was visible. When the animation starts, 
they get reset. For example, I saw the height go from 346, down to 1 and 
back up to 346. Similar when checking the overflow style. You need to make 
sure the element is present before you start inspecting the properties.

Checking the overflow as Titus mentioned seems to be the most robust, at 
least for this specific implementation:

def continue_as_guest
  browser.div(id: 'slide-dialog-container').wait_until do |s|
s.present? &&
s.style('overflow') == 'visible'
  end
  continue_as_guest_element.click
end

Justin


On Tuesday, September 25, 2018 at 2:42:02 PM UTC-4, Justin Ko wrote:
>
> Element#height didn't work for me. It was returning height of the div 
> including the part cut-off by the overflow. The clientHeight gave the 
> height excluding the cut-off portion.
>
> Justin
>
>
> On Tuesday, September 25, 2018 at 2:33:06 PM UTC-4, Titus Fortner wrote:
>>
>> Also, Watir has a `Element#height` method, so you shouldn't need to 
>> resort to JS to get that value.
>>
>>
>>
>> On Tuesday, September 25, 2018 at 11:31:32 AM UTC-7, Titus Fortner wrote:
>>>
>>> Yeah, it's clicking, but I suspect JS event isn't ready to act yet. 
>>>
>>> Note the style transition attributes there. Try waiting for the element 
>>> style to not include "overflow" after the element becomes present. You can 
>>> also try waiting for the size of the slide dialog container to equal some 
>>> value, but that's more hacky. :)
>>>
>>>
>>>
>>> On Tuesday, September 25, 2018 at 9:04:27 AM UTC-7, NaviHan wrote:
>>>>
>>>> Hi Titus & Justin
>>>>
>>>> My theory of actually clicking the button before the pop is fully 
>>>> loaded could be wrong, because even if its not fully loaded the click on 
>>>> "continue as guest" should dismiss the popup.
>>>>
>>>> Please see the video here 
>>>>
>>>>
>>>> https://drive.google.com/file/d/1ycWdST29FptgOS5GYDfRuAPUVBfeQt3h/view?usp=sharing
>>>>
>>>> But what made me think that the button is actually clicked is the 
>>>> screenshot taken at the point of failure, which has a highlighter around 
>>>> the "continue as guest" button which indicated the button is clicked.
>>>>
>>>> https://i.imgur.com/TdhYPz4.png
>>>>
>>>> Both are contradictory.
>>>>
>>>> What do you think?
>>>>
>>>>
>>>> On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>>>>>
>>>>> Its been some days I found this issue untill I understood today the 
>>>>> cause of failure.
>>>>>
>>>>> The behavior is
>>>>> a. The user enters the email on check out page
>>>>> b. A pop up skids in from the top of the page
>>>>> c. The user clicks a "continue as guest "button on the pop up
>>>>> d. The pop up skids back in and disappears
>>>>> e. Verify the pop up disappeared
>>>>>
>>>>> The issue is between step b and step c there is a time when the pop up 
>>>>> is sliding into the page until its loaded completely. During this time 
>>>>> the 
>>>>> script clicks the dismiss button. Because the pop hasent completed 
>>>>> loading 
>>>>> the click doesn't make it disappear.
>>>>>
>>>>> Similarly becasue the pop up takes time to slide back and disapper the 
>>>>> check at step e fails.
>>>>>
>>>>> For the time being Im working around this issue with sleeps. But is 
>>>>> there a neater way?
>>>>>
>>>>>
>>>>> The pop up is defined as 
>>>>>
>>>>> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>>>>>
>>>>>
>>>>> The code that does the job is 
>>>>>
>>>>> def continue_as_guest
>>>>>   continue_as_guest_element.wait_until(&:present?).click
>>>>> end
>>>>>
>>>>>
>>>>> After sleep, which works fine
>>>>>
>>>>> def continue_as_guest
>>>>>   sleep 5
>>>>>   continue_as_guest_element.wait_until(&:present?).click
>>>>>   sleep 5
>>>>> end
>>>>>
>>>>>
>>>>> Note:- I have also tried to wait_while(&:present?) still the issue 
>>>>> stays the same
>>>>>
>>>>> def continue_as_guest
>>>>>   
>>>>> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
>>>>> end
>>>>>
>>>>>
>>>>>
>>>>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-25 Thread Justin Ko
Element#height didn't work for me. It was returning height of the div 
including the part cut-off by the overflow. The clientHeight gave the 
height excluding the cut-off portion.

Justin


On Tuesday, September 25, 2018 at 2:33:06 PM UTC-4, Titus Fortner wrote:
>
> Also, Watir has a `Element#height` method, so you shouldn't need to resort 
> to JS to get that value.
>
>
>
> On Tuesday, September 25, 2018 at 11:31:32 AM UTC-7, Titus Fortner wrote:
>>
>> Yeah, it's clicking, but I suspect JS event isn't ready to act yet. 
>>
>> Note the style transition attributes there. Try waiting for the element 
>> style to not include "overflow" after the element becomes present. You can 
>> also try waiting for the size of the slide dialog container to equal some 
>> value, but that's more hacky. :)
>>
>>
>>
>> On Tuesday, September 25, 2018 at 9:04:27 AM UTC-7, NaviHan wrote:
>>>
>>> Hi Titus & Justin
>>>
>>> My theory of actually clicking the button before the pop is fully loaded 
>>> could be wrong, because even if its not fully loaded the click on "continue 
>>> as guest" should dismiss the popup.
>>>
>>> Please see the video here 
>>>
>>>
>>> https://drive.google.com/file/d/1ycWdST29FptgOS5GYDfRuAPUVBfeQt3h/view?usp=sharing
>>>
>>> But what made me think that the button is actually clicked is the 
>>> screenshot taken at the point of failure, which has a highlighter around 
>>> the "continue as guest" button which indicated the button is clicked.
>>>
>>> https://i.imgur.com/TdhYPz4.png
>>>
>>> Both are contradictory.
>>>
>>> What do you think?
>>>
>>>
>>> On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:

 Its been some days I found this issue untill I understood today the 
 cause of failure.

 The behavior is
 a. The user enters the email on check out page
 b. A pop up skids in from the top of the page
 c. The user clicks a "continue as guest "button on the pop up
 d. The pop up skids back in and disappears
 e. Verify the pop up disappeared

 The issue is between step b and step c there is a time when the pop up 
 is sliding into the page until its loaded completely. During this time the 
 script clicks the dismiss button. Because the pop hasent completed loading 
 the click doesn't make it disappear.

 Similarly becasue the pop up takes time to slide back and disapper the 
 check at step e fails.

 For the time being Im working around this issue with sleeps. But is 
 there a neater way?


 The pop up is defined as 

 button(:continue_as_guest, :class => ['button', 'close-dialog-button'])


 The code that does the job is 

 def continue_as_guest
   continue_as_guest_element.wait_until(&:present?).click
 end


 After sleep, which works fine

 def continue_as_guest
   sleep 5
   continue_as_guest_element.wait_until(&:present?).click
   sleep 5
 end


 Note:- I have also tried to wait_while(&:present?) still the issue 
 stays the same

 def continue_as_guest
   
 continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
 end





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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-25 Thread Justin Ko
It looks like the button itself isn't sliding. The div that contains it is 
actually increasing in height. So my previous suggestions about waiting for 
the button to stop moving doesn't work.
  
I'm still not quite clear on how the click is getting intercepted. However, 
waiting for the section to full expand beyond the button seems to work (at 
least based on what I guessed was the equivalent Production site):
  
def continue_as_guest
  btn = continue_as_guest_element
  scroll_container = browser.div(id: 'slide-dialog-container')
  btn.wait_until { btn.present? && browser.execute_script('return 
arguments[0].clientHeight;', scroll_container) >= btn.center.y }
  btn.click
end

Justin

On Tuesday, September 25, 2018 at 12:04:27 PM UTC-4, NaviHan wrote:
>
> Hi Titus & Justin
>
> My theory of actually clicking the button before the pop is fully loaded 
> could be wrong, because even if its not fully loaded the click on "continue 
> as guest" should dismiss the popup.
>
> Please see the video here 
>
>
> https://drive.google.com/file/d/1ycWdST29FptgOS5GYDfRuAPUVBfeQt3h/view?usp=sharing
>
> But what made me think that the button is actually clicked is the 
> screenshot taken at the point of failure, which has a highlighter around 
> the "continue as guest" button which indicated the button is clicked.
>
> https://i.imgur.com/TdhYPz4.png
>
> Both are contradictory.
>
> What do you think?
>
>
> On Tuesday, 25 September 2018 14:41:15 UTC+10, NaviHan wrote:
>>
>> Its been some days I found this issue untill I understood today the cause 
>> of failure.
>>
>> The behavior is
>> a. The user enters the email on check out page
>> b. A pop up skids in from the top of the page
>> c. The user clicks a "continue as guest "button on the pop up
>> d. The pop up skids back in and disappears
>> e. Verify the pop up disappeared
>>
>> The issue is between step b and step c there is a time when the pop up is 
>> sliding into the page until its loaded completely. During this time the 
>> script clicks the dismiss button. Because the pop hasent completed loading 
>> the click doesn't make it disappear.
>>
>> Similarly becasue the pop up takes time to slide back and disapper the 
>> check at step e fails.
>>
>> For the time being Im working around this issue with sleeps. But is there 
>> a neater way?
>>
>>
>> The pop up is defined as 
>>
>> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>>
>>
>> The code that does the job is 
>>
>> def continue_as_guest
>>   continue_as_guest_element.wait_until(&:present?).click
>> end
>>
>>
>> After sleep, which works fine
>>
>> def continue_as_guest
>>   sleep 5
>>   continue_as_guest_element.wait_until(&:present?).click
>>   sleep 5
>> end
>>
>>
>> Note:- I have also tried to wait_while(&:present?) still the issue stays 
>> the same
>>
>> def continue_as_guest
>>   
>> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
>> end
>>
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to handle behavior while pop up loads, is sleep is the only solution?

2018-09-25 Thread Justin Ko
(Sorry, if some of this repeats Titus's response. I was half way through 
this when he replied.)

If I'm envisioning the sliding correctly, I believe what happens is:
1. The button starts sliding on to the page (at which point it'll be 
considered present)
2. The coordinates of the button are retrieved, however this will be some 
point along the slide path (rather than the final destination)
3. The click is sent to the coordinates, which since the button has since 
moved, will not click the button
4. The button reaches it's final destination

Ideally, you would find something that indicates that the animation has 
completed. I was recently told that jQuery has some property to check for 
its animations. You could see if there is something similar in your 
application. Waiting on this would likely be the most robust approach.

The quickest solution, would be to directly fire the click event, without 
worrying about click coordinates. This would make the script less like a 
user, but might be acceptable.

def continue_as_guest
  continue_as_guest_element.fire_event(:onclick)
end

If you want to maintain the more user-like behaviour, you could wait for 
the button to reach it's final destination before doing the click. If final 
destination is known, you could do:

def continue_as_guest
  btn = continue_as_guest_element
  btn.wait_until do |btn|
  center = btn.center
  center.x == 464 && center.y == 173 # using your expected coordinates
  end
  btn.click
end

If you don't know the exact destination, you could do some polling:

def continue_as_guest
  btn = continue_as_guest_element
  initial_center = btn.center
  btn.wait_until do |btn|
  sleep(1) # assuming the animation moves fast enough
  new_center = btn.center
  initial_center.x == new_center.x && new_center.y == new_center.y
  end
  btn.click
end

Justin

On Tuesday, September 25, 2018 at 11:30:48 AM UTC-4, Titus Fortner wrote:
>
> This kind of dynamic code is difficult.
>
> Firstly, `wait_until(&:present?).click` is currently redundant. The wait 
> will happen automatically if you just do: `click` 
>
> Essentially the driver is processing the element as displayed before the 
> desired action is attached to that element.  Ideally, the front end devs 
> add classes that indicate the status of the transitions that can be polled 
> specifically before acting.
>
> If this is being done through a specific JS framework (like jQuery or 
> Angular), you can do a generic wait for that framework's activity to be 
> complete (see watir_angular gem or PageObject's JavascriptFrameworkFacade 
> for JQuery)
>
> The final and hackiest approach I have used in the past is to implement an 
> `#ensure_click` method where you specify the condition that has to be met 
> for the click to be successful, and re-click if it is not. But this is 
> inherently tricky because of all the race conditions possible.
>
>
>
> On Monday, September 24, 2018 at 9:41:15 PM UTC-7, NaviHan wrote:
>>
>> Its been some days I found this issue untill I understood today the cause 
>> of failure.
>>
>> The behavior is
>> a. The user enters the email on check out page
>> b. A pop up skids in from the top of the page
>> c. The user clicks a "continue as guest "button on the pop up
>> d. The pop up skids back in and disappears
>> e. Verify the pop up disappeared
>>
>> The issue is between step b and step c there is a time when the pop up is 
>> sliding into the page until its loaded completely. During this time the 
>> script clicks the dismiss button. Because the pop hasent completed loading 
>> the click doesn't make it disappear.
>>
>> Similarly becasue the pop up takes time to slide back and disapper the 
>> check at step e fails.
>>
>> For the time being Im working around this issue with sleeps. But is there 
>> a neater way?
>>
>>
>> The pop up is defined as 
>>
>> button(:continue_as_guest, :class => ['button', 'close-dialog-button'])
>>
>>
>> The code that does the job is 
>>
>> def continue_as_guest
>>   continue_as_guest_element.wait_until(&:present?).click
>> end
>>
>>
>> After sleep, which works fine
>>
>> def continue_as_guest
>>   sleep 5
>>   continue_as_guest_element.wait_until(&:present?).click
>>   sleep 5
>> end
>>
>>
>> Note:- I have also tried to wait_while(&:present?) still the issue stays 
>> the same
>>
>> def continue_as_guest
>>   
>> continue_as_guest_element.wait_until(&:present?).tap(&:click).wait_while(&:present?)
>> end
>>
>>
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.

[wtr-general] Re: Maybe look in an iframe? error when clicking button

2018-09-20 Thread Justin Ko
Sounds like the timing issue. Maybe try waiting for the coupon to be 
removed before continuing:

delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.tap(&:
click).wait_while(&:present?)

Justin



On Thursday, September 20, 2018 at 9:30:17 AM UTC-4, NaviHan wrote:
>
> Hi Justin
>
> The button collection is defined as
>
> buttons(:delete_coupon, :id => 'delete-coupon')
>
>
> On Thursday, 20 September 2018 20:50:21 UTC+10, NaviHan wrote:
>>
>> I have a bag page where I have applied two coupons. Once the coupons are 
>> applied the source looks like this
>> 
>>
>>
>> Applied codes:
>>
>> 
>> 
>> 
>> 9840150120702065
>> 
>> 
>> 
>> > "delete-coupon">
>> 
>> Remove
>> 
>> 
>> 
>>
>>
>> 
>> 
>> 
>> autotest_order
>> 
>> 
>> 
>> > "delete-coupon">
>> 
>> Remove
>> 
>> 
>> 
>>
>> 
>>
>>
>>
>> There is a remove link(button) against each coupon. Basically my test 
>> clicks these buttons to remove them
>>
>> I have the page object defined as and the step def and method as follows
>>
>> buttons(:delete_coupon, :id => 'delete-coupon')
>>
>>
>>
>>
>> And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |
>> table|
>>   on(MybagPage) do |page|
>> @remove_voucher_list = table.hashes
>> @remove_voucher_list.each {|data|
>>   page.remove_voucher_from_bag data['voucher_id']
>> }
>>   end
>>
>>
>> def remove_voucher_from_bag coupon_id
>>   delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
>> end
>>
>>
>> The script removes the coupon "9840150120702065", but when trying to 
>> remove the next coupon fails with folowing message
>> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
>> waiting for #"delete-coupon", 
>> :tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
>> ./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block 
>> in remove_voucher_from_bag'
>>
>>
>>
>> Any clue whats missing here?
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How to take full screen, screenshots after test fails

2018-09-20 Thread Justin Ko
Hi Navi,

Selenium only screenshots the content in the viewport. If you want the 
whole browser, you would need to take multiple screenshots.

There was a gem recently released to do this - 
https://github.com/samnissen/watir-screenshot-stitch

Though I haven't tried it myself.

Justin


On Thursday, September 20, 2018 at 7:14:17 AM UTC-4, NaviHan wrote:
>
> Hi 
>
> I have put this code in the hooks which takes scresnshot when a test 
> fails. The issue is that Im not getting the full browser screen. Its chops 
> off at the bottom
>
> After do |scenario|
>  take_screenshot(@browser, scenario)
> end
>
>
> def take_screenshot(browser, scenario)
>   time = Time.now.strftime("%Y-%m-%d_%H%M")
>   if scenario.failed?
> scenario_name = scenario.name.gsub(/[^\w\-]/, ' ')
> screenshot_path =  "#{scenario_name}" + "_failure_" + time
> @browser.screenshot.save("./screenshots/#{screenshot_path}.png")
>   end
> end
>
>
> By the way my before hooks looks like this.
>
> Before do|scenario|
> ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
> @browser.goto "https://www.sandbox.paypal.com;
> @browser.cookies.clear
> @browser.goto "https://portal-sandbox.afterpay.com;
> @browser.cookies.clear
> @browser.goto "https://i-pay.co.za;
> @browser.cookies.clear
> @browser.goto("ci.XXX.com/")
> @browser.window.maximize
> @browser.driver.manage.timeouts.implicit_wait = 0
> @browser.cookies.clear
> @browser.driver.manage.window.maximize
> PageObject.default_element_wait=(10)
> PageObject.javascript_framework = :jquery
> end #before scenario
>
>
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Maybe look in an iframe? error when clicking button

2018-09-20 Thread Justin Ko
Hi Navi,

How is #delete_coupon_elements defined? I would have expected it to 
re-determine the collection each time it was called.

Titus made some fixes around collections in 6.13 and 6.14. You could see if 
that resolves your issue.

I suppose it could be a timing issue - eg :
1. The first coupon button is clicked (but not immediately removed from the 
UI due to asychronous code)
2. The coupon collection is re-calculated (still 2 since the first is still 
not deleted)
3. The first coupon actually gets removed
4. The locating of the second button is no longer possible.

Alternatively, there isn't a benefit of iterating over the collection of 
coupons. Technically, it's slower. You could locate and delete the specific 
coupon:

def remove_voucher_from_bag coupon_id
  browser.button(id: 'delete-coupon', value: coupon_id).click
end

Justin

On Thursday, September 20, 2018 at 6:50:21 AM UTC-4, NaviHan wrote:
>
> I have a bag page where I have applied two coupons. Once the coupons are 
> applied the source looks like this
> 
>
>
> Applied codes:
>
> 
> 
> 
> 9840150120702065
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
>
> 
> 
> 
> autotest_order
> 
> 
> 
>  "delete-coupon">
> 
> Remove
> 
> 
> 
>
> 
>
>
>
> There is a remove link(button) against each coupon. Basically my test 
> clicks these buttons to remove them
>
> I have the page object defined as and the step def and method as follows
>
> buttons(:delete_coupon, :id => 'delete-coupon')
>
>
>
>
> And(/^the customer removes the coupons\/vouchers from Bag Page$/) do |
> table|
>   on(MybagPage) do |page|
> @remove_voucher_list = table.hashes
> @remove_voucher_list.each {|data|
>   page.remove_voucher_from_bag data['voucher_id']
> }
>   end
>
>
> def remove_voucher_from_bag coupon_id
>   delete_coupon_elements.find{|el| el.value.to_s == coupon_id.to_s}.click
> end
>
>
> The script removes the coupon "9840150120702065", but when trying to 
> remove the next coupon fails with folowing message
> Watir::Exception::UnknownObjectException: timed out after 30 seconds, 
> waiting for #"delete-coupon", 
> :tag_name=>"button", :index=>1}> to be located; Maybe look in an iframe?
> ./features/support/pages/Frontend/Cotton_On/Mybag_Page.rb:141:in `block 
> in remove_voucher_from_bag'
>
>
>
> Any clue whats missing here?
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: wait_for_ajax method in PageObject gem, how to use in hooks?

2018-09-12 Thread Justin Ko
Hi Navi,

I don't think you'll be able to directly call Page-Object's #wait_for_ajax 
from an after hook. You'll have to do the wait directly.

I believe you said you were using jQuery. Where you are initializing the 
browser, add the following line to add the after_hook:

browser = Watir::Browser.new 
browser.after_hooks.add do |browser|
  browser.wait_until { browser.execute_script('return jQuery.active;') == 0 
}
end

Justin

On Tuesday, September 11, 2018 at 12:56:11 AM UTC-4, NaviHan wrote:
>
> We did discuss this previously. Im trying to find a way to use 
> wait_for_ajax for each and every element.
>
> Titus or Justin has earlier suggested to move this to the hooks.rb file.
>
> Could you guys tell me how to use it in hooks?
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: How often to get element reference, best practice?

2018-09-11 Thread Justin Ko
In that example, you should just #add_to_bag.

I'm guessing that you are working with a code base that is older than Watir 
6.0. Before v6.0, add_to_bag_element.when_present.click was required for 
elements that were not immediately present on page load (ie you needed to 
wait for them to appear). In Watir 6.0, Titus made changes to automatically 
wait for elements before taking actions. As a result, pre-6.0 
add_to_bag_element.when_present.click would be equivalent to v6.0 
add_to_bag_element.click. add_to_bag_element.click is equivalent to the 
accessor created add_to_bag.

In general, I would say:
- You do not need the waits when taking actions (eg click, inputting, etc) 
on an element.
- Use the page object accessor's methods if available (ie don't duplicate 
the framework)

Justin


On Tuesday, September 11, 2018 at 12:52:33 AM UTC-4, NaviHan wrote:
>
> This is something that keeps me a bit sceptic when I write and read the 
> automation code in my project.
> This used PageObjects.
>
> I have seen extensive use of element referces, for example 
>
> button(:add_to_bag, :css => '#add-to-cart')
> add_to_bag.element.when_present.click
>
>
>
> instead of 
>
> add_to_bag 
>
> which directly clicks the element
>
> I have also seen extensive use of referencing elements using 
> .when_present, .wait_until_present etc
>
> Im confused where we should draw the line when deciding to reference the 
> element and actually using it(as in directly calling "add_o_bag" in the above 
> example to click the element.
>
> Any thoughts?
>
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Justin Ko
I agree that adding it to the after hooks adds overhead. Though at 0.015s 
per click, it's not the worst thing in the world. 

I worked on one application where almost every button/link click triggered 
a loading overlay. Creating a method for each button/link to add the wait 
would defeat the purpose of using the Page Object gem. As with anything, 
the "better way" really depends on the application you're testing.

Justin


On Tuesday, August 7, 2018 at 1:00:37 PM UTC-4, rajagopal...@gmail.com 
wrote:
>
> Okay, I will be waiting for that then! There was a new project in my 
> company for which I convinced them to use WATIR instead of Selenium where I 
> had to implement this waiting behavior! Okay excited to see this new 
> feature to be added!   Thanks.
>
> On Tuesday, August 7, 2018 at 10:24:55 PM UTC+5:30, Titus Fortner wrote:
>>
>> you'll be able to specify the exact desired behaviours in a more granular 
>> way
>>
>> On Tue, Aug 7, 2018, 9:53 AM  wrote:
>>
>>> Oh okay. But you said 
>>>
>>> The Executor class when implemented will open up a lot more flexibility.
>>>
>>>
>>> So will it be lesser wire call after Executor class implemented? Can I 
>>> add after that?  
>>>
>>> On Tuesday, August 7, 2018 at 10:18:51 PM UTC+5:30, Titus Fortner wrote:
>>>>
>>>> No, your way is better if it is working for you. Adding it to the after 
>>>> hook will add a ton more unnecessary calls to your code.
>>>>
>>>>
>>>> On Tue, Aug 7, 2018 at 9:38 AM  wrote:
>>>>
>>>>> That will be interesting, I am using as shown below, 
>>>>>
>>>>>>
>>>>>> def selectAndWait(locator, value)
>>>>>>   select locator, value
>>>>>>   waitForPageLoad
>>>>>> end
>>>>>>
>>>>>> def waitForPageLoad
>>>>>>   @b.wait_until(timeout: @Page_Load) {@b.execute_script("return 
>>>>>> (jQuery.active === 0)").eql? true}
>>>>>> end
>>>>>>
>>>>>>
>>>>>
>>>>> Let me try using this `after_hook`, a very interesting idea indeed.
>>>>> On Tuesday, August 7, 2018 at 9:59:47 PM UTC+5:30, Titus Fortner wrote:
>>>>>>
>>>>>> after any action that changes or is likely to change the dom, so it 
>>>>>> can get heavy if overused. The Executor class when implemented will open 
>>>>>> up 
>>>>>> a lot more flexibility.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Aug 7, 2018, 9:27 AM  wrote:
>>>>>>
>>>>>>> Ah! that's pretty interesting, I was not knowing this. So you say 
>>>>>>> Once I have written this code, this code will be executed after every 
>>>>>>> click 
>>>>>>> I do? 
>>>>>>>
>>>>>>> On Tuesday, August 7, 2018 at 9:54:17 PM UTC+5:30, Titus Fortner 
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> jquery_wait = lambda { |br| br.wait_until { |b| 
>>>>>>>> b.execute_script('return jQuery.active == 0') } } 
>>>>>>>> browser.after_hooks.add(jquery_wait)
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tuesday, August 7, 2018 at 9:17:32 AM UTC-7, 
>>>>>>>> rajagopal...@gmail.com wrote:
>>>>>>>>>
>>>>>>>>> Hi Justin, 
>>>>>>>>>
>>>>>>>>> We are also using this wait_for_ajax in one of our Project. You 
>>>>>>>>> said 
>>>>>>>>>
>>>>>>>>> I would suggest adding the jQuery.active check to your browser's 
>>>>>>>>>> after_hooks. Ideally this would catch all (or at least most) of the 
>>>>>>>>>> problems.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> May I know how to do this?  
>>>>>>>>>
>>>>>>>>> On Tuesday, August 7, 2018 at 9:37:42 PM UTC+5:30, Justin Ko wrote:
>>>>>>>>>>
>>>>>>>>>> The #wait_for_ajax simplifies things if you need to manually call 
>>>>>>>>>> it. However, it sounds like you would h

Re: [wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Justin Ko
The #wait_for_ajax simplifies things if you need to manually call it. 
However, it sounds like you would have to sprinkle this everywhere.

I would suggest adding the jQuery.active check to your browser's 
after_hooks. Ideally this would catch all (or at least most) of the 
problems.

Note that there would be a small performance hit of making this check after 
each click/goto. However, if it's an AJAX heavy application, it's probably 
worth it.

Justin


On Tuesday, August 7, 2018 at 11:36:54 AM UTC-4, Titus Fortner wrote:
>
> Found it 
>
> See the section on Waiting for AJAX Calls here: 
> http://cheezyworld.com/2012/02/23/page-object-0-6-2-released/ 
> let's you call `wait_for_ajax` where you want it. 
>
>
> On Tue, Aug 7, 2018 at 7:43 AM NaviHan > 
> wrote: 
> > 
> > Yes Justin, That was exactly what happened. I ran the script a few times 
> and using "Watir::Wait.until(timeout: 30) {@browser.execute_script('return 
> jQuery.active == 0')}" never gave me the error " 
> > 
> > Element ... is not clickable at 
> point (537, 362). Other element would receive the click:  class="loader-bg">" 
> > 
> > 
> > The code is 
> > 
> > def select_online_size (size) 
> >   Watir::Wait.until(timeout: 30) {@browser.execute_script('return 
> jQuery.active == 0')} 
> >   sizes_online_elements.find {|el| el.when_present.text.eql? size}.click 
> > end 
> > 
> > I was expecting that the "when_present" method would not give any timing 
> issue because this waits until the element is present. Somehow this 
> evaulates to true at the same time the spinner which is loading while the 
> Ajax is running receives the click. 
> > 
> > 
> > Is there a PO way to resolve this , I mean without having to use the 
> "jQuery" statement 
> > 
> > 
> > Cheers 
> > 
> > Navi 
> > 
> > On Friday, 3 August 2018 15:12:45 UTC+10, NaviHan wrote: 
> >> 
> >> I have a functionality where I click an a link from an email a voucher 
> gets added to the shopping cart and a pop up appears with a message. Im 
> trying to assert the text in the popup 
> >> I have defined the element as 
> >> 
> >> div(:cta_description, :css => '.homepage-clicktoactiavte-description') 
> >> 
> >> Tried to use a mix of Watir and Pageobejct to read the text. The below 
> code works 5 out of 10 times. 
> >> 
> >> @rewards_popup_txt = Watir::Wait.until{cta_description_element}.text 
> >> @rewards_popup_txt = @rewards_popup_txt.gsub(/[^$,.A-Za-z0-9]/," ") 
> >> return @rewards_popup_txt 
> >> 
> >> 
> >> Tried using, which doesnt even set the @reward_popup_txt and shows 
> error 
> >> 
> >> 
> >> if (Watir::Wait.while {cta_description_element.visible?}) 
> >>   @rewards_popup_txt = cta_description_element.text 
> >> end 
> >> @rewards_popup_txt = @rewards_popup_txt.gsub(/[^$,.A-Za-z0-9]/," ") 
> >> return @rewards_popup_txt 
> >> 
> >> Error 
> >> NoMethodError: undefined method `gsub' for nil:NilClass 
> >> ./features/support/pages/Frontend/Cotton_On/Loyalty_Page.rb:22:in 
> `rewards_popup_description' 
> >> 
> >> Any stable way to do the job? 
> > 
> > -- 
> > -- 
> > 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. 
> > 
> > watir-...@googlegroups.com  
> > http://groups.google.com/group/watir-general 
> > watir-genera...@googlegroups.com  
> > --- 
> > 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 watir-genera...@googlegroups.com . 
> > 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble reading the text from Popup , Using Watir and Pageobject

2018-08-07 Thread Justin Ko
Hi Navi,

Just to be clear, are you saying that "Watir::Wait.until(timeout: 30) {
@browser.execute_script('return jQuery.active == 0')}" solves the timing 
issue? You are just asking if there is a Page Object way to avoid doing 
this manually everywhere?

Thanks,
Justin


On Tuesday, August 7, 2018 at 8:27:15 AM UTC-4, NaviHan wrote:
>
> Hi Titus
>
> I found a good deal of documentation from PageObject wiki so was able to 
> substitue the waits with PageObject equivalent.
> https://github.com/cheezy/page-object/wiki/Ajax-Calls
>
> Still the issue with spinner(Loader.bg) holds and Im working this around 
> using "Watir::Wait.until(timeout: 30) {@browser.execute_script('return 
> jQuery.active == 0')}"
>
> Is there any solution in PageObject gem to handle this is still an open 
> question. Do you reckon I could get some help somewhere?
>
> I would require your help to clear my doubts about "wait while" and "wait 
> until". I see this is something extensively used in out project but no one 
> has a clear answer.A grep gave me this
>
> ./features/support/pages/Frontend/COG/Checkout_Page.rb:Watir::Wait.
> while {order_summ_content_element.visible?}
> ./features/support/pages/Frontend/COG/Paypal_Page.rb:Watir::Wait.while 
> {paypal_logo_element.visible?}
> ./features/support/pages/Frontend/COG/Paypal_Page.rb:Watir::Wait.while 
> {paypal_spinner_element.visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:if Watir::Wait.while 
> {olapped_sm_window_element.visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:# Watir::Wait.while 
> {stores_elements[9].visible?}
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:Watir::Wait.while {
> stores_elements[9].visible?}
> ./features/support/pages/Frontend/COG/Thankyou_Page.rb:return Watir::
> Wait.while {@browser.text.include?('Did you enjoy your shopping 
> experience today')}
>
>
> And Wait.until is used everywhere and the list is huge
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:# 
> Watir::Wait.until {check_stores_element}.click
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:  #return 
> Watir::Wait.until {el}.parent(:index => 1).attribute('class') if 
> el.text.include? "#{size}"
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:  #return 
> Watir::Wait.until {el}.parent.attribute('class') if 
> el.span_element.text.include? "#{size}"
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:#return 
> Watir::Wait.until {search_string_element}.attribute('value')
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:#return 
> Watir::Wait.until {search_string_element}.attribute('value')
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:@succ_txt = 
> Watir::Wait.until {pdp_success_msg_block_element}.text
> ./features/support/pages/Frontend/COG/Pdp_Page.rb:Watir::Wait.
> until(timeout: 30){add_to_bag_element.enabled?}
> ./features/support/pages/Frontend/COG/Search_Page.rb:Watir::Wait.
> until {search_field_element}.when_present.clear
> ./features/support/pages/Frontend/COG/Search_Page.rb:Watir::Wait.
> until {search_field_element}.when_present.click
> ./features/support/pages/Frontend/COG/Search_Page.rb:Watir::Wait.
> until {search_field_element}.when_present.set(arg)
>
> I dont get any idea out of this..
>
>
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-12 Thread Justin Ko

>
> 1. Just like we do plural for div, I mean divs, isnt there plural version 
> for select_list i:e select_lists? Similarly buttons?
> How do we know if there is a plural version at all. I couldn't find 
> the documentation.
>

The plural version `#select_lists` does exist. I don't think there is any 
up-to-date documentation for the list of accessors, but I believe the 
plural version is always defined. You can see what is defined in the 
Accessors module - `#select_lists` is dynamically defined at the end of the 
module 
(https://github.com/cheezy/page-object/blob/master/lib/page-object/accessors.rb#L1162-L1172).
 

> 2. If two elements have the same attribute, for example say there are 
> multiple divs and multiple select lists with class name starting with 
> "dwfrm_cart_shipments" 
> and if we define the object as below
>   
> elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/)
>
> Does this identify both the divs and the select_lists.
> And later we pass this to a block and filter the specific element by a 
> specific attribute. (Like you identified the select_list with attribute "
> data_product_id"
>

Yes, `#elements` will include all tag types - ie you'll have a collection 
of divs and selects. If you know you only want a specific tag, you should 
use that respective method. 
 

> 3. With the attribute "data_product_id", is there a reason you have used 
> underscore(_) instead of hyphens (-)
>

Hyphens are not valid characters in method and symbol names. As a result, 
Watir chose to use underscores. Watir will switch all of the underscores to 
hypens when looking up the attribute value.
 

> 4. Could you please explain the use of "map(&:text)" called on elements?
>

`elements.map(&:text)` will return an Array containing the text of each 
element. It's equivalent to:
texts = []
elements.each { |e| texts << e.text }

Justin

>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-11 Thread Justin Ko
The accessors do not provide a mechanism for filtering the element 
collection. In other words, the exception is from 
`product_line_items_in_bag_elements(:"data-product-id" => '9350486827327')`.

You can filter the elements manually using `#find`:

class MyPage
  include PageObject

  elements(:product_line_items_in_bag, :name => /^dwfrm_cart_shipments/) # 
note that you need a regex here
end

page = MyPage.new(browser)
products = page.product_line_items_in_bag_elements
product = products.find { |e| e.data_product_id == '9351533670743' }
product.select('2')

However, it'd be easier to skip the accessor and define a method. This 
allows locating the select list directly, which can save execution time.

class MyPage
  include PageObject

  def product_element(product_id)
browser.select_list(data_product_id: product_id)
  end
end

Justin


On Wednesday, July 11, 2018 at 6:22:20 AM UTC-4, NaviHan wrote:
>
> Hi Justin/Titus
>
> There is a correction in the html code
>
> 
> 
> 
> 
>  id="dwfrm_cart_shipments_i0_items_i0_quantity" 
> name="dwfrm_cart_shipments_i0_items_i0_quantity" 
> data-product-id="9350486558733" data-item-position="1" aria-invalid="false">
>
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
> 
> 
> 
> 
>  id="dwfrm_cart_shipments_i0_items_i1_quantity" 
> name="dwfrm_cart_shipments_i0_items_i1_quantity" 
> data-product-id="9351533670743" data-item-position="2">
>
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
> 
> 
> 
> 
>  id="dwfrm_cart_shipments_i0_items_i2_quantity" 
> name="dwfrm_cart_shipments_i0_items_i2_quantity" 
> data-product-id="9351533671290" data-item-position="3" aria-invalid="false">
>
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
>
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> This is my first post here. Apologies if there is a mistake.
>>
>> I have a section of a page as attached in the pic.
>>
>>
>> The html code for the section is as follows
>> Enter code here...
>> 
>> 
>> 9830318220466018
>> 
>>  
>> > data-gift-id="9830318220466018">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>> 
>> 9831228610400260
>> 
>>  
>> > data-gift-id="9831228610400260">
>> 
>> Remove
>> 
>> 
>> 
>> 
>> 
>>
>> I need to assert two value here
>>
>> 1. The vouchers applied, which are 9830318220466018 & 9831228610400260
>> 2. The span "Remove"
>>
>> The issue Im facing is as these two divs are identical and 1 & 2 doesnt 
>> have a unique identifier I cannt locate them using PageObjects.
>>
>> I can locate the element using the following Java script
>> document.getElementsByClassName('applied-voucers-list')[0].innerText;
>> This returns 
>> Enter code here..."9830318220466018
>> Remove
>> "
>>
>> I tried to capture this with the code
>> Enter code here...@var = 
>> @browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
>>
>> This isnt working
>>
>> Any clue?
>>
>>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Trouble Locating elements using PageObject

2018-07-10 Thread Justin Ko
Hi,

Accessing the spans within minimum_spend_threshold_error would be similar 
to what you did with nav_div_elements:

page.minimum_spend_threshold_error_element.span_elements[0].html
#=> ""

page.minimum_spend_threshold_error_element.span_elements[1].html
#=> "Sorry, your Perks Payday Voucher will be removed if you proceed 
to checkout"

You could also define them in the page object to make the usage easier:

class MyPage
  include PageObject

  div(:minimum_spend_threshold_error, :class => 'perk-validation-error')
  div(:first_span) { minimum_spend_threshold_error_element.span_elements[0] 
}
  div(:second_span) { minimum_spend_threshold_error_element.span_elements[1] 
}
end

page.first_span_element.html
#=> ""

page.second_span_element.html
#=> "Sorry, your Perks Payday Voucher will be removed if you proceed 
to checkout"

Hope that helps,
Justin


On Tuesday, July 10, 2018 at 2:54:01 AM UTC-4, NaviHan wrote:
>
> Hi Titus
>
> I have got a related query
>
> I have a section of page
> 
> 
> 
> 
> 
> Sorry, your Perks Payday Voucher will be removed if you 
> proceed to checkout
> This reward is only available on orders AUD 10.00 and over.
> 
> 
>
> If I define the outer div as div (:minimum_spend_threshold_error, :class 
> => 'perk-validation-error'), how do I access the first span and second span?
>
> Thanks in advance
>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: can you run the scripts on Win10\ chrome? Used to be working a while ago

2018-06-27 Thread Justin Ko

>
> The question regarding Chrom is still valid. Can anyone drive the chrome 
> and goto an url on win 10?
>

Chrome works for me on Windows 10 Pro using:
- Watir 6.11
- Selenium-WebDriver 3.13
- Chrome 67
- Chromedriver 2.4

Justin

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: how can I click an

2018-06-22 Thread Justin Ko
@rajagopalan, I don't know enough about the internal workings of JavaScript 
or Webdriver to be sure. But my guess would be:

   - Browsers do not fully support click events for  elements - eg 
   https://stackoverflow.com/q/3487263/1200545
   - As a result WebDriver has defined special logic simulating a click, 
   which includes interacting with the select element - see definition 
   https://www.w3.org/TR/webdriver/#element-click
   
Justin


On Friday, June 22, 2018 at 3:39:05 PM UTC-4, rajagopalan madasami wrote:
>
> Hi Justin, have you ever try to click option using JavaScript click, it is 
> not choosing as selenium click towards the option would choose the option . 
> But button click remain the same for both, do know why it is ?
>
> On 23-Jun-2018 1:06 AM, "Justin Ko" > 
> wrote:
>
> Do you try using the :id locator? It looks like you might have crossed 
> your attributes/values - ie the attempts are checking the "fielddisplayname" 
> attribute, but looking for the id value.
>
> Try:
>
> @browser.a(id: "Employee_ID").click
>
> If #click isn't working, you could also try #click!
>
> @browser.a(id: "Employee_ID").click!
>
> - Justin
>
>
> On Friday, June 22, 2018 at 12:36:22 PM UTC-4, christina wrote:
>
>> Is not ok because all other attributes have the same link.
>>
>> I have to identify in a unique way.
>>
>> Please let me know how Thank you!
>>
>> On Fri, Jun 22, 2018 at 11:31 AM, c w  wrote:
>>
>>> That worked:
>>>
>>> @browser.link(:class, "peoplefield editable editable-click 
>>> editable-empty").fire_event:click  
>>>
>>>
>>>
>>> -- Forwarded message --
>>> From: c w 
>>> Date: Fri, Jun 22, 2018 at 11:03 AM
>>> Subject: how can I click an >> on edit mode for a field
>>> To: watir-...@googlegroups.com
>>>
>>>
>>>
>>> Hi all,
>>>
>>> Please help me and Thank you!
>>> In order to edit these attribute I have to click on the "empty" which is 
>>> a javascript:;
>>>
>>> Please can one tell me how can I click on the Employee_id field to 
>>> edit...
>>> If I will be able to do this tho others should be similar.
>>>
>>> I have try few things but these are not working:
>>> @browser.a(fielddisplayname: "Employee_ID").click
>>>   @browser.a(fielddisplayname: "Employee_ID").fire_event:click
>>>   @browser.a(:class, ' peoplefield editable editable-click 
>>> editable-empty').click
>>>   
>>>   @browser.a(fielddisplayname: "Employee_ID").fire_event('onclick')
>>> @browser.link(:xpath, "//a[@onclick='javascript:;']").click  
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> -- 
> -- 
> 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.
>  
> watir-...@googlegroups.com 
> http://groups.google.com/group/watir-general
> watir-genera...@googlegroups.com 
> --- 
> 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 watir-genera...@googlegroups.com .
> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: how can I click an

2018-06-22 Thread Justin Ko
Do you try using the :id locator? It looks like you might have crossed your 
attributes/values - ie the attempts are checking the "fielddisplayname" 
attribute, but looking for the id value.

Try:

@browser.a(id: "Employee_ID").click

If #click isn't working, you could also try #click!

@browser.a(id: "Employee_ID").click!

- Justin


On Friday, June 22, 2018 at 12:36:22 PM UTC-4, christina wrote:
>
> Is not ok because all other attributes have the same link.
>
> I have to identify in a unique way.
>
> Please let me know how Thank you!
>
> On Fri, Jun 22, 2018 at 11:31 AM, c w > 
> wrote:
>
>> That worked:
>>
>> @browser.link(:class, "peoplefield editable editable-click 
>> editable-empty").fire_event:click  
>>
>>
>>
>> -- Forwarded message --
>> From: c w >
>> Date: Fri, Jun 22, 2018 at 11:03 AM
>> Subject: how can I click an > on edit mode for a field
>> To: watir-...@googlegroups.com 
>>
>>
>>
>> Hi all,
>>
>> Please help me and Thank you!
>> In order to edit these attribute I have to click on the "empty" which is 
>> a javascript:;
>>
>> Please can one tell me how can I click on the Employee_id field to edit...
>> If I will be able to do this tho others should be similar.
>>
>> I have try few things but these are not working:
>> @browser.a(fielddisplayname: "Employee_ID").click
>>   @browser.a(fielddisplayname: "Employee_ID").fire_event:click
>>   @browser.a(:class, ' peoplefield editable editable-click 
>> editable-empty').click
>>   
>>   @browser.a(fielddisplayname: "Employee_ID").fire_event('onclick')
>> @browser.link(:xpath, "//a[@onclick='javascript:;']").click  
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>

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

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: visible_text is deprecated

2017-12-13 Thread Justin Ko
Sorry, no, these changes are not available in 6.10.1.

There are still changes I want to do for the simplify_locator branch. 
However, if the current state solves your problem, I can see if I get 
something merged in sooner.

Justin


On Wednesday, December 13, 2017 at 1:42:05 AM UTC-5, rajagopal...@gmail.com 
wrote:
>
> This change available in recent water 6.10.1?
>
> On Tuesday, December 12, 2017 at 11:39:51 PM UTC+5:30, Justin Ko wrote:
>>
>> Rajagopalan, would you be able to see if the changes I have made in 
>> https://github.com/jkotests/watir/tree/simplify_locator fixes the 
>> performance problem for :visible_text?
>>
>> I think the problem is where we filter elements:
>>
>> def filter_elements_by_locator(elements, visible = nil, visible_text = 
>> nil, idx = nil, tag_name: nil, filter: :first) 
>>   elements.select! { |el| visible == el.displayed? } unless visible.nil? 
>>   elements.select! { |el| visible_text === el.text } unless visible_text.
>> nil? 
>>   elements.select! { |el| element_validator.validate(el, {tag_name: 
>> tag_name}) } unless tag_name.nil? 
>>   filter == :first ? elements[idx || 0] : elements 
>> end
>>
>>
>> We apply the filter to every element found, even if you just want the 
>> first one. The changes I have in progress switch this to be lazy - ie we 
>> would only need to inspect the first link that matches. For a page with a 
>> lot of links, I believe this would increase performance a lot.
>>
>> Justin
>>
>>
>> On Tuesday, December 12, 2017 at 12:56:46 PM UTC-5, rajagopalan madasami 
>> wrote:
>>>
>>> I am using watir over selenium for two reasons, one reason is waiting 
>>> timings are maintained by local language binding but selenium is 
>>> maintaining timing from driver level , since selenium uses the timing from 
>>> driver level it differs from Firefox to Chrome, but since WATIR is 
>>> maintaining timing from local language binding it doesn't matter whether I 
>>> use Chrome or Firefox. Another reason is stale element problem, WATIR 
>>> relocates the element when element  goes to stale other than that I don't 
>>> use any other features of WATIR because everything else is time consuming 
>>> like xpah formation. So if you simply allow element () to access selenium 
>>> locators directly it would be useful for me rather than unnecessary 
>>> deprecating what word extraordinary.
>>>
>>> On 12-Dec-2017 11:06 PM, "Titus Fortner" <titusf...@gmail.com> wrote:
>>>
>>>> Hey Chuck,
>>>>
>>>> Especially with Watir 6, there are some good synchronization reasons to 
>>>> prefer Watir over default selenium, even if not taking advantage of the 
>>>> improved encapsulation of the subclasses or the more advanced locator 
>>>> strategies. Though, not so many that it might not be worth it for him to 
>>>> roll his own at that point. Depends on how much else in the Watir 
>>>> ecosystem 
>>>> he is relying on.
>>>>
>>>> Titus
>>>>
>>>>
>>>>
>>>>
>>>> On Tuesday, December 12, 2017 at 11:20:28 AM UTC-6, Chuck van der 
>>>> Linden wrote:
>>>>>
>>>>> bah... need to be able to edit... I confused using .link method of 
>>>>> watir with the :link locator type of Selenium... please disregard the 
>>>>> confusion over that sentence.
>>>>>
>>>>> Point being however that you seem wedded to directly using .element 
>>>>> and selenium selection methods, so the question of why even use Watir as 
>>>>> opposed to Selenium, given your preferences, still exists. 
>>>>>
>>>>> On Tuesday, December 12, 2017 at 9:17:10 AM UTC-8, Chuck van der 
>>>>> Linden wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Monday, December 11, 2017 at 10:29:52 PM UTC-8, 
>>>>>> rajagopal...@gmail.com wrote:
>>>>>>>
>>>>>>> Can you please pay a little attention to the ongoing conversation? 
>>>>>>> The conversation is not about using element() or using link() function, 
>>>>>>> the 
>>>>>>> conversation is about performance issue while I use visible text. I am 
>>>>>>> ready to use visible text If it does the good performance but it's not 
>>>>>>> doing it, I am trying to click a link which takes m

Re: [wtr-general] Re: visible_text is deprecated

2017-12-12 Thread Justin Ko
Rajagopalan, would you be able to see if the changes I have made in 
https://github.com/jkotests/watir/tree/simplify_locator fixes the 
performance problem for :visible_text?

I think the problem is where we filter elements:

def filter_elements_by_locator(elements, visible = nil, visible_text = nil, 
idx = nil, tag_name: nil, filter: :first) 
  elements.select! { |el| visible == el.displayed? } unless visible.nil? 
  elements.select! { |el| visible_text === el.text } unless visible_text.nil
? 
  elements.select! { |el| element_validator.validate(el, {tag_name: tag_name
}) } unless tag_name.nil? 
  filter == :first ? elements[idx || 0] : elements 
end


We apply the filter to every element found, even if you just want the first 
one. The changes I have in progress switch this to be lazy - ie we would 
only need to inspect the first link that matches. For a page with a lot of 
links, I believe this would increase performance a lot.

Justin


On Tuesday, December 12, 2017 at 12:56:46 PM UTC-5, rajagopalan madasami 
wrote:
>
> I am using watir over selenium for two reasons, one reason is waiting 
> timings are maintained by local language binding but selenium is 
> maintaining timing from driver level , since selenium uses the timing from 
> driver level it differs from Firefox to Chrome, but since WATIR is 
> maintaining timing from local language binding it doesn't matter whether I 
> use Chrome or Firefox. Another reason is stale element problem, WATIR 
> relocates the element when element  goes to stale other than that I don't 
> use any other features of WATIR because everything else is time consuming 
> like xpah formation. So if you simply allow element () to access selenium 
> locators directly it would be useful for me rather than unnecessary 
> deprecating what word extraordinary.
>
> On 12-Dec-2017 11:06 PM, "Titus Fortner"  > wrote:
>
>> Hey Chuck,
>>
>> Especially with Watir 6, there are some good synchronization reasons to 
>> prefer Watir over default selenium, even if not taking advantage of the 
>> improved encapsulation of the subclasses or the more advanced locator 
>> strategies. Though, not so many that it might not be worth it for him to 
>> roll his own at that point. Depends on how much else in the Watir ecosystem 
>> he is relying on.
>>
>> Titus
>>
>>
>>
>>
>> On Tuesday, December 12, 2017 at 11:20:28 AM UTC-6, Chuck van der Linden 
>> wrote:
>>>
>>> bah... need to be able to edit... I confused using .link method of watir 
>>> with the :link locator type of Selenium... please disregard the confusion 
>>> over that sentence.
>>>
>>> Point being however that you seem wedded to directly using .element and 
>>> selenium selection methods, so the question of why even use Watir as 
>>> opposed to Selenium, given your preferences, still exists. 
>>>
>>> On Tuesday, December 12, 2017 at 9:17:10 AM UTC-8, Chuck van der Linden 
>>> wrote:



 On Monday, December 11, 2017 at 10:29:52 PM UTC-8, 
 rajagopal...@gmail.com wrote:
>
> Can you please pay a little attention to the ongoing conversation? The 
> conversation is not about using element() or using link() function, the 
> conversation is about performance issue while I use visible text. I am 
> ready to use visible text If it does the good performance but it's not 
> doing it, I am trying to click a link which takes minutes to click that 
> link but when I use link locator it clicks instantly. 
>

  You say that, yet every code example I see from you uses .element

 Then we have statements like this:

>  Yes, I agree using b.link() increases the performance, But I 
> completely against the idea of not using the link: locator of selenium.


 (given the sentence makes no sense if parsed using the double negative 
 (in which case you would already be using .link, which you are not),  I 
 presume that 'not' in the above is a typo) 

 So despite people telling you to use .link, you seem insistent on using 
 .element.  which is basically the same as using raw Webdriver instead of 
 Watir.  So frankly I don't think my question is that out of line.  If you 
 insist on using .element, and are as you stated 'completely against the 
 idea' of using the watir API, then why use Watir and not just use 
 webdriver 
 directly?

 In terms of performance: 
 As Titus asked earlier, can you provide a code example that 
 demonstrates the performance difference you are claiming to see?  not a 
 discussion of code, but actual code against an actual site. 

>>> -- 
>> -- 
>> Before posting, please read http://watir.com/support. In short: search 
>> before you ask, be nice.
>>  
>> watir-...@googlegroups.com 
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com 
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Watir 

[wtr-general] Re: visible_text is deprecated

2017-12-10 Thread Justin Ko
Yes, the plan is to remove :link, :link_text and :partial_link_text.

It is known that using :visible_text will not have the same performance. It 
has to iterate over elements, where as the Selenium ones would not. The 
benefit of :visible_text is that we can apply it across all element types, 
not just links.

I have a number of ideas for improving locator performance in general. 
However, for this specific case, you will see performance improvements by 
not using #element. Just switching to using #link will cut down the number 
of elements Watir has to iterate over. If there are other locators to 
reduce the links checked, that will also help performance. If that doesn't 
help, a specific example would help us identify other places for 
performance improvements.

Justin


On Sunday, December 10, 2017 at 2:24:19 AM UTC-5, rajagopal...@gmail.com 
wrote:
>
> When I use
>
> b.element(link: 'Book Now').click
>
> it says 
>
> 2017-12-10 12:49:01 WARN Watir [DEPRECATION] :link locator is deprecated. 
> Use :visible_text instead.
>
> Does that mean it would be removed in future? 
>
> because what I found is, visible_text locator is not working properly, it 
> clicks the link after 3 to 5 mins of time, How funny, Isn't it? 
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Unable to use API Locators using Watir 6.8.4

2017-11-29 Thread Justin Ko
How did you define `@b`?

Based on the exception and behaviours you are seeing, it sounds like you've 
created a Selenium::WebDriver instead of a Watir::Browser. The 
initialization should be like:

@b = Watir::Browser.new

- Justin


On Wednesday, November 29, 2017 at 3:45:21 PM UTC-5, Jeff Fagot wrote:
>
> Hello all,
>
> As a new user, I find myself using online posts to make progress and 
> discoveries on things I ignore.
> Based on various posts I found out about the existence of the "API 
> Locators" such as .div(s) or .span(s)...etc
>
> Even if I am still wondering about their usage after reading about this 
> discussion : 
> https://groups.google.com/forum/#!topic/watir-general/G90898izxc4
>
> *QUESTION:* I am still wondering why are the "API Locators" such as 
> .div(s), .span(s), .element(), .table(s) not working for me knowing that I 
> am using Watir 6.8.4? 
>
>
> *EXAMPLE*:
> *   _   **HTML sample__*
>   /  
> /
>  /   /
> /_/
>
>__WATIR
>   /  /
>  /   fltr_dates = @b.tables(:class, "month1")/
> /___/
>
>
> *ACTUAL RESULT*:
>
> Whenever I try .table(s), .element() or .div  ...etc...I am getting this 
> kind of error:
> *  undefined method `tables' for 
> # (NoMethodError)*
>
> I am only able to use .find_element(s) to locate an element.
>__WATIR__
>   /
>   /
>  /   fltr_dates = @b.find_elements(:class, "month1")   /
> /_/
>
>
> *What did I try*:
> 1) I searched online if anyone had encountered this issue, or to make sure 
> that those API Locator where still in use on Watir 6.8.4. I found the 
> discussion posted above that comforted me in the idea that these are still 
> in use in version 6+ of Watir
> 2) I have verify and I am getting the same  error no matter 
> the browser I use (Chrome, Firefox or IE).
>
> *Hypotheses*: I am wondering if this has anything to do with an 
> incompatibility of gems mixed together?
>
> Here is my full list of gems:
>
> *** LOCAL GEMS ***
>
> backports (3.9.1)
> bigdecimal (1.2.8)
> builder (3.2.3)
> bundler (1.15.4)
> childprocess (0.8.0)
> cucumber (3.0.1)
> cucumber-core (3.0.0)
> cucumber-expressions (4.0.4)
> cucumber-tag_expressions (1.0.1)
> cucumber-wire (0.0.1)
> did_you_mean (1.0.0)
> diff-lcs (1.3)
> ffi (1.9.18 x86-mingw32)
> gherkin (4.1.3)
> io-console (0.4.5)
> json (1.8.3)
> minitest (5.8.5)
> multi_json (1.12.2)
> multi_test (0.1.2)
> net-telnet (0.1.1)
> power_assert (0.2.6)
> psych (2.1.0)
> rainbow (2.2.2)
> rake (10.4.2)
> rdoc (4.2.1)
> rspec (3.6.0)
> rspec-core (3.6.0)
> rspec-expectations (3.6.0)
> rspec-mocks (3.6.0)
> rspec-support (3.6.0)
> rubyzip (1.2.1)
> selenium-webdriver (3.6.0)
> test-unit (3.1.5)
> watir (6.8.4)
>
> Thanks for your help in this matter.
>
> Regards,
> Jeff Fagot
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: link and link_text not working in Watir 6?

2017-10-19 Thread Justin Ko

>
> If you try to use something like browser.link(text: "Services").click, it 
> says:
>
> "element located, but timed out after 30, seconds."
>

 The problem here is that there are actually 2 services links on the page. 
One is in the mobile nav menu (when the browser width is small) and one is 
in the full site menu (when the browser with is wide). `browser.link` grabs 
the first matching element, which in this case is the one in the nav menu. 
The element exists, but never becomes visible. Depending on what browser 
width you want to work with, you need to either:

   1. Expand the menu (for smaller browser widths):
   browser.div(id: 'mob-burger-trigger').click
   browser.link(text: 'Services').click
   
   2. Click the visible (or second) services link (for wider browser 
   widths):
   browser.link(text: 'Services', visible: true).click
   

If I do the more generic element: browser.element(link_text: 
> "Services").click, I get:
>
> "timeout after 30 seconds." (So it just couldn't find it at all.)
>
 
Interestingly, :link_text appears to take into account the text styling. If 
you view the source, the HTML text is just "Services". However, there is a 
style applying a text-transform which makes it look like "SERVICES" in the 
UI. The :link_text locator appears to consider the transform. As a result, 
you need to use the capitalized value:

browser.element(link_text: 'SERVICES').click

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: link and link_text not working in Watir 6?

2017-10-19 Thread Justin Ko
: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, inve...@gmail.com 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:
>
> Services
>
> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: document object could not be used in watir-webdriver

2017-07-04 Thread Justin Ko
In general, you can achieve a similar interaction with the "document" 
object by using the `execute_script` method.

For example, the line:

control.document.invoke("currentStyle").backgroundColor

Could be re-written as (assuming that "control" is a Watir::Element):

browser.execute_script('return arguments[0].currentStyle.backgroundColor', 
control)

However, `currentStyle` is only defined in IE11, not Edge. As a result, the 
above will not work in Edge. Instead you will need to use the 
`getComputedStyle` method:

browser.execute_script('return 
window.getComputedStyle(arguments[0]).backgroundColor;', control)

For this specific example, you can simply this further by using Watir's 
built-in `style` method instead:

control.style('background-color')

- Justin Ko


On Tuesday, July 4, 2017 at 11:41:33 AM UTC-4, AROCKIA JERALD wrote:
>
> Hi all,
>
> I am migrating from watir-classic to watir-webdriver  to support ms edge 
> browser testing. I am facing an issue with *document object *which was 
> specific to IE. There is no direct way to refer document object using 
> watir-webdriver. Below is the code am referring and its exception. Can this 
> group help me on this to overcome this issue?
>
> *Code:*
>
> Watir::Wait.until(@entrySelectionTimeout) {
>   
> ((control.document.invoke("currentStyle").backgroundColor).eql? 
> @selectedColor) &&
>(is_status_bar_visible?.eql? false)
>}
>
> *Exception:*
>
>  Exception: undefined method `document' for 
> #
>
> *Environment Used:*
>
> Ruby Version - 2.2.6p396
>
> *Gems used*
> commonwatir (3.0.0)
> watir (6.2.1)
> watir-classic (4.3.0)
> watir-webdriver (0.9.9)
>
>
> is there any options to achieve my requirement as per the above code which 
> uses *webdriver*? However, same things were working perfectly fine with 
> watir-classic.
>  
>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Selenium clicks the line but WATIR doesn't click the same link, So there is a bug the way WATIR identifying the Link

2017-03-28 Thread Justin Ko
The difference appears to be that `b.link(:text, 'Recharge')` includes 
hidden links, where as `driver.find_element(:link, 'Recharge')` only 
includes visible links.

The page includes 8 links with the matching text:

Recharge

Recharge
https://www.airtel.in/netbanking/payments-recharges; 
data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank 
WithUs> Savings Account > Manage Account > Recharge')">Recharge
https://www.airtel.in/netbanking/payments-recharges; 
data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank 
WithUs> Wallet > Transact > Recharge')">Recharge
https://www.airtel.in/netbanking/payments-recharges; 
data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank 
WithUs> Savings Account > Manage Account > Recharge')">Recharge
https://www.airtel.in/netbanking/payments-recharges; 
data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank 
WithUs> Wallet > Transact > Recharge')">Recharge
https://www.airtel.in/netbanking/payments-recharges; 
data-i18n="recharge" module-id="common">Recharge
https://www.airtel.in/netbanking/payments-recharges; 
data-i18n="recharge" module-id="common">Recharge

However, only the 2nd one, which is the one you want, is visible:

b.links(:text, 'Recharge').map(&:visible?)
#=> [false, true, false, false, false, false, false, false]

You get an exception in Watir because it is clicking on the first one, 
which is hidden. You could simulate what Selenium is doing by adding the 
visible locator:

b.link(text: 'Recharge', visible: true).click

Justin


On Tuesday, March 28, 2017 at 12:41:35 PM UTC-4, Raja gopalan wrote:
>
> This is the link "https://www.airtel.in/; once you entered, please click "PAY 
> & RECHARGE"   then you will have Recharge option. 
>
>
> On Tuesday, March 28, 2017 at 9:34:08 AM UTC-7, Titus Fortner wrote:
>>
>> Apparently you included the link in an earlier post that I missed. It 
>> does look like Watir is grabbing a different, hidden element. I'll try to 
>> take a longer look at it tonight.
>>
>> Titus
>>
>> On Tuesday, March 28, 2017 at 11:24:16 AM UTC-5, Raja gopalan wrote:
>>>
>>> hi, sorry, that was not done properly, here is the html file
>>>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Recharge
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> On Monday, March 27, 2017 at 9:32:57 PM UTC-7, Titus Fortner wrote:

 This html doesn't have any links with text equal to "Recharge"


 On Monday, March 27, 2017 at 11:13:03 PM UTC-5, Raja gopalan wrote:
>
> Here is the Html code
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Pay Bill
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Savings Account
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> http://schema.org/WebSite; itemscope="">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> var _gaq = _gaq || []; 
> _gaq.push(['_setAccount', 'UA-35987772-1']); 
> _gaq.push(['_setDomainName', 'airtel.in']); 
> _gaq.push(['_setAllowLinker', true]); 
> _gaq.push(['_setAllowAnchor', true]); 
> _gaq.push(['_addIgnoredRef', '
> airtel.in']); _gaq.push(['_trackPageview']); (function() { 
>  var ga = document.createElement('script'); ga.type = 
> 'text/javascript'; ga.async = true; 
> //ga.src = ('https:' == document.location.protocol ? 'https://' : 
> 'http://') + '
> stats.g.doubleclick.net/dc.js'; 
> ga.src = ('app/libs/edited/homepage/dc.js?version=1490500432236'); 
> var s = document.getElementsByTagName('script')[0]; 
> s.parentNode.insertBefore(ga, s); 
> })();
> 
> 
> 
> 
>
> On Monday, March 27, 2017 at 2:13:16 PM UTC-7, Titus Fortner wrote:
>>
>> 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  
>> 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/;
>>>  @driver=@b.driver
>>>  @driver.manage.timeouts.implicit_wait=10
>>>  end
>>>
>>>  def execute

[wtr-general] Re: goto method not found

2016-10-04 Thread Justin Ko
The "type: :request" is added when Rails is detected, which happened during 
your installation. As a result, each of the configurations only applies to 
examples groups that have the same metadata of "type: :request". I am not a 
Rails developer, so I cannot explain the rationale for adding the filter. 
At any rate, instead of removing the filter, you could have also gotten the 
tests to run by adding the metadata to the example group - ie 
"RSpec.describe "Google", type: :request do"

In terms of getting the second test to run, it looks there have been some 
changes in the layout of the Google results. I had to update the test to be:

  it "allows to search" do
text_field(name: "q").set "watir"

# Changed the locator, as well as added when_present to wait for the 
layout changes
button(name: "btnG").when_present.click

results = div(id: "ires")
expect(results).to be_present.within(2)

# Changed to look at divs instead of lis
expect(results.divs(class: "g").map(&:text)).to be_any { |text| text =~ 
/watir/ }

expect(results).to be_present.during(1)
  end

Justin


On Tuesday, October 4, 2016 at 2:37:39 PM UTC-4, artie.z...@gmail.com wrote:
>
> Thanks very much for the dialog on this, Justin. 
> I know your time must be valuable.  
>
> Well, perhaps the mystery deepens. :)
> At least for me it does. Lot for me to learn here. 
>
> Indeed, this entire block (with comments) was inside my 
> ./spec/spec_helper.rb file:
>
> require "watir/rspec"
>
> RSpec.configure do |config|
>   config.add_formatter(:progress) if config.formatters.empty?
>   config.add_formatter(Watir::RSpec::HtmlFormatter)
>
>
>   config.before :all, type: :request do
> @browser = Watir::Browser.new
>   end
>
>
>   config.after :all, type: :request do
> @browser.close if @browser
>   end
>
>   config.include Watir::RSpec::Helper, type: :request
>   config.include Watir::RSpec::Matchers, type: :request
> end
>
>
>
> My Terminal scroll-back indicates I ran the installer:
> $ watir-rspec install
> Rails application detected.
> Installing watir-rspec configuration into 
> /Users/dks/Projects/spiker/spec/spec_helper.rb.
>
> Can anyone elaborate on the reason why the removal of the four occurrences 
> of "type: :request", creates conditions where the goto appears to work 
> properly. Well, honestly I did not try with only two or three. I removed 
> all four. 
>
> In fact, the sample "google url" script on the github page appears to work 
> to completion on my system. 
>
> May I ask further... in the sample script, why does the second test fail? 
> I tried to fix it by changing the search string that presumably referenced 
> the CSS id of the "Google Search" and "Feeling Lucky" button. However, when 
> I change it to any reasonable id I discover when using GoogleChrome 
> Developer Inspect Tool. I get various errors, including selenium 
> ElementNotVisibleError, and Watir UnknownMethodException. I would not think 
> making the second test pass was this challenging. Ha! How to make it pass?
>
> Many thanks.
> AZ
>
>
> On Tuesday, October 4, 2016 at 8:50:02 AM UTC-7, Justin Ko wrote:
>>
>> When I ran the install, the following was added to the spec_helper (with 
>> the comments removed for brevity):
>>
>> require "watir/rspec"
>>
>> RSpec.configure do |config|
>>   config.add_formatter(:progress) if config.formatters.empty?
>>   config.add_formatter(Watir::RSpec::HtmlFormatter)
>>
>>   config.before :all do
>> @browser = Watir::Browser.new
>>   end
>>
>>   config.after :all do
>> @browser.close if @browser
>>   end
>>
>>   config.include Watir::RSpec::Helper
>>   config.include Watir::RSpec::Matchers
>> end
>>
>>
>> The "goto" method is added to examples by the "config.include 
>> Watir::RSpec::Helper" line. Though you will likely want to include all of 
>> these lines if you are just starting out.
>>
>> Justin
>>
>>
>>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: goto method not found

2016-10-04 Thread Justin Ko
When I ran the install, the following was added to the spec_helper (with 
the comments removed for brevity):

require "watir/rspec"

RSpec.configure do |config|
  config.add_formatter(:progress) if config.formatters.empty?
  config.add_formatter(Watir::RSpec::HtmlFormatter)

  config.before :all do
@browser = Watir::Browser.new
  end

  config.after :all do
@browser.close if @browser
  end

  config.include Watir::RSpec::Helper
  config.include Watir::RSpec::Matchers
end


The "goto" method is added to examples by the "config.include 
Watir::RSpec::Helper" line. Though you will likely want to include all of 
these lines if you are just starting out.

Justin


On Tuesday, October 4, 2016 at 11:28:23 AM UTC-4, artie.z...@gmail.com 
wrote:
>
> Thank you very much for your reply
> Yes, I ran install. 
> IIRC correctly there were two lines of output. 
> I did not make a copy of the spec_helper before I ran the install. 
> What should I look for in there?
>
> thanks!
> -AZ
>
>
> On Tuesday, October 4, 2016 at 6:52:30 AM UTC-7, Justin Ko wrote:
>>
>> It sounds like the Watir::RSpec::Helper has not been added to the example 
>> groups.
>>
>> Did you run the "watir-rspec install" (see last step of installation)? 
>> The install augments your project's spec_helper file to include this module 
>> and other related parts.
>>
>> In terms of the debugging question, I do not have much advice. With 
>> undefined method errors, I suppose you need to figure out where the method 
>> is supposed to be defined and then figure out why it isn't being included. 
>> If you have some familiarity with RSpec and Watir, you might be able to 
>> guess that "goto" method is being done by Watir-RSpec. You can dig through 
>> the code to figure out where it defines the "goto" method - though this one 
>> is a bit difficult since it is implemented using method_missing in the 
>> Watir::RSpec::Helper. From there, you would look at why it is not being 
>> included in your RSpec config, which might lead you to noticing your 
>> spec_helper hasn't been updated.
>>
>> Justin
>>
>>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: goto method not found

2016-10-04 Thread Justin Ko
It sounds like the Watir::RSpec::Helper has not been added to the example 
groups.

Did you run the "watir-rspec install" (see last step of installation)? The 
install augments your project's spec_helper file to include this module and 
other related parts.

In terms of the debugging question, I do not have much advice. With 
undefined method errors, I suppose you need to figure out where the method 
is supposed to be defined and then figure out why it isn't being included. 
If you have some familiarity with RSpec and Watir, you might be able to 
guess that "goto" method is being done by Watir-RSpec. You can dig through 
the code to figure out where it defines the "goto" method - though this one 
is a bit difficult since it is implemented using method_missing in the 
Watir::RSpec::Helper. From there, you would look at why it is not being 
included in your RSpec config, which might lead you to noticing your 
spec_helper hasn't been updated.

Justin


On Tuesday, October 4, 2016 at 9:22:58 AM UTC-4, artie.z...@gmail.com wrote:
>
> Hello!
>
> I want to use watir-rspec . After 
> finding this google group, I see a post announcing a new release from 
> jarmo. So, I must be in the right place, finally. 
>
> Is the recent release of watir-rspec known to work?
>  
> I tried the "Google" example (exactly as shown). It is the one on the 
> watir-rspec github home page. 
>
> There is some issue "seeing" the "goto" method. 
>
> I'd like to know how somebody can perform debugging an error like this:
>
> NoMethodError:
>undefined method `goto' for 
> #
>
> Is there a way I can learn to determine what the root cause of this issue?
>
> Of course, if I modify the script and insert initialize a "browser" 
> variable explicitly in the before clause, like this, things appear to work 
> fine:
> browser = Watir:Browser.new :chrome
> browser.goto("http://www.google.com/;)
>
> FTR (and to help me solve this), I am using ruby 2.3.1 and here is my gem 
> list:
>
> [{2.3.1}]~: ➭ gem list
>
> *** LOCAL GEMS ***
>
> actioncable (5.0.0.1)
> actionmailer (5.0.0.1)
> actionpack (5.0.0.1)
> actionview (5.0.0.1)
> activejob (5.0.0.1)
> activemodel (5.0.0.1)
> activerecord (5.0.0.1)
> activesupport (5.0.0.1)
> addressable (2.4.0)
> arel (7.1.2)
> bigdecimal (default: 1.2.8)
> builder (3.2.2)
> bundler (1.13.2)
> byebug (9.0.6)
> capybara (2.9.1)
> childprocess (0.5.9)
> coderay (1.1.1)
> coffee-rails (4.2.1)
> coffee-script (2.4.1)
> coffee-script-source (1.10.0)
> concurrent-ruby (1.0.2)
> debug_inspector (0.0.2)
> did_you_mean (1.0.0)
> diff-lcs (1.2.5)
> erubis (2.7.0)
> execjs (2.7.0)
> ffi (1.9.14)
> globalid (0.3.7)
> i18n (0.7.0)
> io-console (default: 0.4.5)
> jbuilder (2.6.0)
> jquery-rails (4.2.1)
> json (default: 1.8.3)
> listen (3.0.8)
> loofah (2.0.3)
> mail (2.6.4)
> method_source (0.8.2)
> mime-types (3.1)
> mime-types-data (3.2016.0521)
> mini_portile2 (2.1.0)
> minitest (5.9.1, 5.8.3)
> multi_json (1.12.1)
> net-telnet (0.1.1)
> nio4r (1.2.1)
> nokogiri (1.6.8)
> pkg-config (1.1.7)
> power_assert (0.2.6)
> pry (0.10.4)
> psych (default: 2.0.17)
> puma (3.6.0)
> rack (2.0.1)
> rack-test (0.6.3)
> rails (5.0.0.1)
> rails-dom-testing (2.0.1)
> rails-html-sanitizer (1.0.3)
> railties (5.0.0.1)
> rake (11.3.0, 10.4.2)
> rb-fsevent (0.9.7)
> rb-inotify (0.9.7)
> rdoc (default: 4.2.1)
> rspec (3.5.0)
> rspec-core (3.5.4, 3.5.3)
> rspec-expectations (3.5.0)
> rspec-mocks (3.5.0)
> rspec-rails (3.5.2)
> rspec-support (3.5.0)
> rubygems-update (2.6.7)
> rubyzip (1.2.0)
> sass (3.4.22)
> sass-rails (5.0.6)
> selenium-webdriver (3.0.0.beta3.1, 2.53.4)
> slop (3.6.0)
> spring (2.0.0)
> spring-watcher-listen (2.0.1)
> sprockets (3.7.0)
> sprockets-rails (3.2.0)
> sqlite3 (1.3.11)
> test-unit (3.1.5)
> thor (0.19.1)
> thread_safe (0.3.5)
> tilt (2.0.5)
> turbolinks (5.0.1)
> turbolinks-source (5.0.0)
> tzinfo (1.2.2)
> uglifier (3.0.2)
> watir (6.0.0.beta5)
> watir-rails (2.0.0)
> watir-rspec (3.0.0)
> watir-webdriver (0.9.3)
> web-console (3.3.1)
> websocket (1.2.3)
> websocket-driver (0.6.4)
> websocket-extensions (0.1.2)
> xpath (2.0.0)
>
>
> Many thanks for any advices.
> AZ
>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: cannot load such file - LoadError

2016-07-12 Thread Justin Ko
As I mentioned in your Stack Overflow question, 
http://stackoverflow.com/q/38274619/1200545, you need to set the 
DataMagic.yml_directory. Note that the yml_directory is the *directory* 
relative to the working directory (see the question for an example). It 
should not be a file (ie should not contain data_form.yml) and it is not 
likely to be relative to env.rb

- Justin Ko


On Monday, July 11, 2016 at 3:49:14 PM UTC-4, Ajay Reddy wrote:
>
> Hello All,
> I am getting this error "cannot load such file 
> -/pages/Config/data/data_form.yml (LoadError)", can any one fix this issue 
> please. 
>
> Here is my scenario:
> Scenario: Verify the xxx
>   Given I am on xxx web page
>   When I provide application information
>   And I select xxx button
>   And I click on xxx
>   Then I should xxx
>
>
> Here is when: 
> When(/^I provide application information$/) do
>   submission = CardSubmission.new(@browser)
>   submission.submit_application
> end
>
>
> Here is cardsubmission class: 
> require "test_data.rb"
> require 'yaml'
> class CardSubmission < Main
>   include PageObject
>   include DataMagic
>   include TestData
>
>   def initialize(browser)
> @browser = browser
>   end
>
>   def submit_application(data = {})
> DataMagic.load ("data_form.yml")
> populate_page_with data_for(:Auto_Data, data)
>   end
>   end
>
> Here the TestData module:
> module TestData
>   include PageObject
> text_field(:name, :id => 'Name')
> text_field(:mail, :id => 'Mail')
> end
>
>
> I am calling the data_magic gem in env: 
> DataMagic.yml_directory = 'pages/Config/data/data_form.yml'
>
>
>
> Thank You,
> Ajay.
>
>
>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Upload multiple files to input element?

2016-05-13 Thread Justin Ko
Last time I checked, Webdriver did not have full support for uploading 
multiple files.

For at least Chrome, a workaround was to use `send_keys` and deliminate the 
files using "\n":

browser.file_field.send_keys("full/path/file1.txt \n full/path/file2.txt")

- Justin Ko


On Friday, May 13, 2016 at 1:41:16 PM UTC-4, jherzen...@shastaqa.com wrote:
>
> It's just a standard input field 
> ``` multiple="multiple">```
>
> It accepts multiple, I'm just not sure how to do that...
> I've tried using `input_element.set paths` with the 'paths' variable as 
> the following:
> ```
> paths = ("/path/to/file/1"; "/path/to/file/2")
> paths = ["/path/to/file/1", "/path/to/file/2"]
> paths = "'path/to/file/1', 'path/to/file/2'"
> ```
>
> On Friday, May 13, 2016 at 6:58:33 AM UTC-7, johnssn wrote:
>>
>> Hi Jesse,
>>
>> What have you tried, what does the HTML look like and what kind of errors 
>> are you getting? It could be many things and that info might narrow down 
>> the possibilities a bit.
>>
>> John
>>
>> --
>> *From:* "jherz...@shastaqa.com" <jherz...@shastaqa.com>
>> *To:* Watir General <watir-...@googlegroups.com> 
>> *Sent:* Thursday, May 12, 2016 7:36 PM
>> *Subject:* [wtr-general] Upload multiple files to input element?
>>
>> Hello everyone
>>
>> I'm having a bit of difficulty trying to automate something that is a 
>> fairly standard procedure.  There is an input element on the page, that 
>> accepts multiple, and I need to upload multiple files to this.  I haven't 
>> been able to find anything on any of the major forums, so I figured I'd 
>> post here and see if any of you know of a solution.  Thanks!
>>
>> Cheers,
>> Jesse
>> -- 
>> -- 
>> Before posting, please read http://watir.com/support. In short: search 
>> before you ask, be nice.
>>  
>> watir-...@googlegroups.com
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com
>>
>> --- 
>> 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 watir-genera...@googlegroups.com.
>> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Reg: iterating a loop in watir web driver

2015-07-31 Thread Justin Ko
The exception is saying that there is no method `table` for 
`@adl_name_search`. Are you sure you are calling the `table` method for the 
right object? It should be called for a Watir::Browser or a Watir::Element.

Once you do get the table element, you can iterate through each td element 
by retrieving a tds collection:

browser.table(:id, 'tableSearchResult').tds.each do |td|
  td.text == @lastname
end

However, since it looks like you want to compare the last name, perhaps you 
want to find the row where the last name matches:

row = browser.table(:id, 'tableSearchResult').trs.find { |tr| tr.td(index: 
0).text == @lastname }

- Justin


On Thursday, July 30, 2015 at 7:42:55 AM UTC-4, VIDYA SAGAR POGIRI wrote:

 Hi i want to iterate the values in a table in watir-web driver, when i use 
 : @adl_name_search.table(:id, 'tableSearchResult')[i][i].text == @lastname 
 , its giving error as :NoMethodError: undefined method `table' for 
 #ADL_namesearchmodpobj:0x31af118 , so kindly help me how to iterate the 
 loop in a table.I have also attached the screen shot. Thanks in advance 


-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Need help how to work with watir testing angularjs app

2015-07-15 Thread Justin Ko
For the checkbox (copied from the answer on Stack Overflow 
http://stackoverflow.com/a/31431597/1200545):

The problem with the checkbox is that it is not an HTML checkbox - ie input 
type=checkbox. Instead it is a md-checkbox, which I believe is from the 
Angular Material library. As a result, Watir's checkbox method will not see 
it.


You will need to treat the md-checkbox as a generic element and use the 
click method to set/clear it:


browser.element(class: 'ng-pristine ng-valid md-default-theme-ng-touched').click


The class attribute does not look unique. You might want to use one of the 
other attributes instead. For example:


browser.element(aria_label: 'Remove').click


- Justin Ko


On Tuesday, July 14, 2015 at 8:49:34 AM UTC-4, Mahesh Mesta wrote:

 Hi,

 I am very new to watir. I have been trying to test the edit profile of an 
 application.I need to set and clear a checkbox, upload an image file and 
 enter some text in the angular rich text editor for testing.However I am 
 not been able to do either three of them.

 (1).For check box the angularjs elements go as follows

 md-checkbox aria-label=Remove aria-invalid=false aria-checked=false 
 tabindex=0 class=ng-pristine ng-valid md-default-theme ng-touched 
 role=checkbox ng-model=user.remove_photo style=margin-top: 0px;div 
 class=md-container md-ink-ripple= md-ink-ripple-checkbox=div 
 class=md-icon/div/divdiv ng-transclude= class=md-labelspan 
 class=ng-scopeRemove/span/div/md-checkbox

 I need to check and uncheck the checkbox.

 (2) For uploading the image file, the elements are as follows

 input aria-invalid=false tabindex=0 class=ng-pristine ng-valid 
 ng-touched ng-model=user.photo 
 onchange=angular.element(this).scope().file_selected(event) type=file
  
  I need to upload a profile pic i.e an image file

 Kindly help me to get the solution for them using watir webdriver. I would 
 really appreciate it.

 Regards,
 Mahesh.




-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Skip external links

2015-07-02 Thread Justin Ko
Instead of building a collection of all links on the page, ie doing 
`browser.links`, you can use locators to build a collection of certain 
links. In this case, you would want to be filtering links based on the 
:href. For example, the collection would be `browser.links(href: 
/mysite\.com/)`.

Here is what the script might look like:

require 'watir-webdriver'
b = Watir::Browser.new :chrome

# Go to the site
b.goto 'mysite.com'

# Find all of the links that include mysite.com in the href
internal_links = b.links(href: /mysite\.com/)

# Iterate through the links
internal_links.each_with_index do |_, i|
  # Go back to the start page
  b.goto 'mysite.com'
  
  # Note that navigating to another page will invalidate our element 
references
  # As a result, we need to re-locate the link using the index
  b.link(href: /mysite\.com/, index: i).click
  
  # Perform actions on the page
  p b.url
end

- Justin Ko


On Monday, June 29, 2015 at 1:40:30 PM UTC-4, Sergiu Cornea wrote:

 Good afternoon guys,

 I was wondering if someone could help me. 

 Please correct me if I am wrong as I have just started learning Watir and 
 Ruby.

 Lets say I have 20 websites to be checked but I don't know the links so 
 what I am doing it is searching for them using the index value as follows:

 require 'watir-webdriver'

 b = Watir::Browser.new
 b.goto mysite.com

 b.links.each_with_index do |_, i|

 b.link(index: i).click
 end

 This piece of code will go and click on all the links that are available 
 on the Home page, however, I want it to just click on the internal links 
 only and not the external ones as well, for example mysite.com/hello, 
 mysite.com/howareyou.

 I have found a work around which is that knowing what index the external 
 websites are you could skip them, however, I believe there must be a way of 
 skipping them by href or so, but because I am new I don't really know.

 Thank you in advance.

 Regards,
 Cip

 This message and its attachments are private and confidential. If you have 
 received this message in error, please notify the sender and remove it and 
 its attachments from your system.

 The University of Westminster is a charity and a company 
 limited by guarantee. Registration number: 977818 England. 
 Registered Office: 309 Regent Street, London W1B 2UW.


-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Drag n Drop not working for me with Firefox version25

2015-03-18 Thread Justin Ko
Selenium's support for Firefox 25 native events ended in version 2.40.0 
(see http://selenium.googlecode.com/git/rb/CHANGES). Selenium only supports 
native events for the latest releases and a couple of extended support 
releases.

You could try downgrading your Selenium-WebDriver gem to version 2.39.0 (ie 
the last release with support for Firefox 25). Depending on the changes, 
you may or may not also need to downgrade Watir-Webdriver to match.

Justin Ko


On Tuesday, March 17, 2015 at 9:02:49 AM UTC-4, Joe Fl wrote:

 Hi Titus,

 Thanks for responding.  I gave that a try and still produce the same 
 result.  Probably something i am doing wrong.  I did not have a lot time 
 yesterday to work through this.

 Joe

 On Mon, Mar 16, 2015 at 12:24 PM, Titus Fortner titusf...@gmail.com 
 javascript: wrote:

 Selenium 2.45 does not currently support Native Events:
 https://github.com/SeleniumHQ/selenium/blob/master/CHANGES#L12

 I haven't used Windows to know how this is or isn't set by default right 
 now, but try explicitly turning it off if you need to like this:
 (http://watirwebdriver.com/firefox/)
 profile = Selenium::WebDriver::Firefox::Profile.new
 profile.native_events = false
 Watir::Browser.new :firefox, :profile = profile

 Titus


 On Mon, Mar 16, 2015 at 10:56 AM, Joe Fl joefl...@gmail.com 
 javascript: wrote:

 Hi,

 I am trying to use the drap drop method for watir-webdriver.

 System:  Windows8
 Browser: Firefox version 25
 Gem versions:  selenium-webdriver (2.45.0)
watir-webdriver (0.7.0)


 Code:

 last_dragable_concept = BrowserClass.new(@browser).get_last_drag_concept_img



 def dragable_targets
   @browser.div(:class = 'dragdrop-dropTarget 
 dragdrop-boundary').tables(:class = /dragdrop-dropTarget/)
 end


 def get_last_drag_concept_img
   dragable_targets[0].imgs(:title = drag_image_name).count - 1
 end


 number_dragable_table = BrowserClass.new(@browser).num_dragable_tables


 def dragable_targets
   @browser.div(:class = 'dragdrop-dropTarget 
 dragdrop-boundary').tables(:class = /dragdrop-dropTarget/)
 end

 def num_dragable_tables
   dragable_targets.count - 1
 end


 BrowserClass.new(@browser).drag_it(last_dragable_concept,number_dragable_table)


 def drag_it(n,table_index)
   drag_on_to = @browser.div(:class = 'dragdrop-dropTarget 
 dragdrop-boundary').table(:class = /dragdrop-dropTarget/, :index = 
 num_dragable_tables)
   sleep 1
   @browser.imgs(:title = drag_image_name)[n].drag_and_drop_on(drag_on_to)
 end



 Error I am receiving is the following:

 message: Cannot perform native interaction: Could not load native events 
 component.
 backtrace: [

 [remote server] 
 file:///C:/Users/my_name~1.EXP/AppData/Local/Temp/webdriver-/extensions/fxdri...@googlecode.com/components/driver-component.js:10571:in
  `generateErrorForNativeEvents', 

 [remote server] 
 file:///C:/Users/my_name~1.EXP/AppData/Local/Temp/webdriver-/extensions/fxdri...@googlecode.com/components/driver-component.js:10615:in
  `FirefoxDriver.prototype.mouseMoveTo', 

 [remote server] 
 file:///C:/Users/my_name~1.EXP/AppData/Local/Temp/webdriver-/extensions/fxdri...@googlecode.com/components/command-processor.js:12274:in
  `DelayedCommand.prototype.executeInternal_/h', 

 [remote server] 
 file:///C:/Users/my_name~1.EXP/AppData/Local/Temp/webdriver-/extensions/fxdri...@googlecode.com/components/command-processor.js:12279:in
  `DelayedCommand.prototype.executeInternal_', 

 [remote server] 
 file:///C:/Users/my_name~1.EXP/AppData/Local/Temp/webdriver-/extensions/fxdri...@googlecode.com/components/command-processor.js:12221:in
  `DelayedCommand.prototype.execute/', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/response.rb:52:in
  `assert_ok', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/response.rb:15:in
  `initialize', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:59:in
  `new', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:59:in
  `create_response', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/default.rb:66:in
  `request', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:40:in
  `call', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:640:in
  `raw_execute', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:618:in
  `execute', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:405:in
  `mouseMoveTo', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/common/mouse.rb:52:in
  `move_to', 

 C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.45.0/lib

[wtr-general] Re: automating httpwatch with watir

2015-03-03 Thread Justin Ko
The API for both Watir-Classic and HttpWatch have changed since that 
example was written. Updating to the latest API, the script would be:

require 'win32ole'
require 'watir-classic'
 
# Open the IE browser using Watir
ie = Watir::Browser.new
 
# Attach HttpWatch
control = WIN32OLE.new('HttpWatch.Controller')
plugin = control.IE.Attach(ie.ie)
 
# Start recording
plugin.Record()
 
# Drive the browser
ie.goto('www.google.ca')
 
# Stop recording
plugin.Stop()
 
# Save the log file
plugin.Log.Save('C:\Documents and Settings\Setup\Desktop\log.hwl')
 
# Close IE
ie.close

- Justin Ko


On Tuesday, February 24, 2015 at 12:38:19 AM UTC-5, Mike McClarin wrote:

 Hi, I am trying to automate httpwatch with watir. Please see my code below:

 require 'win32ole'
 require 'watir'

 # Open the IE browser using Watir
 ie = Watir::IE.new

 # Attach HttpWatch
 control = WIN32OLE.new('HttpWatch.Controller')
 plugin = control.Attach(ie.ie)

 # Start recording
 plugin.Record() 


 When I run this in ruby, i receive the following alert:


 C:\Users\mmcclarin\Desktop\HTTPWatchruby testexample04.rb
 testexample04.rb:5:in `main': uninitialized constant Watir::IE 
 (NameError)



 Any help would be appreciated




-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: how to read the meta content

2014-12-16 Thread Justin Ko
You can use the `content` method to return the value of the content 
attribute:

p browser.meta.content
#= this is variable

Justin


On Tuesday, December 16, 2014 11:41:23 AM UTC-5, christina wrote:

 Hi,

 meta name=description content=this is variable

 Hi Please can one help me an tell how can I read the Content

 for meta tag.


 I have to check many websites and check that the seo has a specific value.

 Kind regards,
 Cristina 


-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: HELP - Acessing password (text) field

2014-11-25 Thread Justin Ko
It looks like there is sometimes a delay in the loading of the iframe 
containing the password field. Adding a wait to the setting of the password 
field solved the problem (at least for me):

browser.iframe(id: ws).text_field(id: claveConsultiva).when_present.set 
'bar'

The `when_present` method tells Watir to wait for the element to appear 
before setting it.

- Justin Ko


On Monday, November 24, 2014 5:49:02 PM UTC-5, Alberto Magalhães wrote:

 same error :-(

 require 'watir-webdriver'
 browser = Watir::Browser.new :chrome
 browser.goto(https://www.santandertotta.pt/pt_PT/Particulares.html;)
 #substituir o USERID pelo user de acesso
 browser.text_field(:name = usr).set foo
 browser.button(:value = Login).click
 #browser.goto '
 https://www.particulares.santandertotta.pt/pagina/indice/0,,276_1_2,00.html?usr=Nome%20de%20Utilizador
 '
 browser.iframe(id: ws).text_field(id: claveConsultiva).set 'bar'
 browser.iframe(id: ws).link(id: login_button).click

 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:10:in
  
 `locate': unable to locate iframe using {:id=ws, :tag_name=iframe} 
 (Watir::Exception::UnknownFrameException)
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in
  
 `assert_exists'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:31:in
  
 `assert_exists'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:532:in
  
 `locate'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in
  
 `assert_exists'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/user_editable.rb:11:in
  
 `set'
 from teste_2.rb:8:in `main'



 On Mon, Nov 24, 2014 at 10:44 PM, Titus Fortner titusf...@gmail.com 
 javascript: wrote:

 I take that back, I had a typo when trying to set. I'm not having any 
 problem with the code...

 2.1.2 :073  browser = Watir::Browser.new :chrome
  = #Watir::Browser:0x1f1ef64532cb8556 url=data:, title=data:, 
 2.1.2 :074  browser.goto(
 https://www.santandertotta.pt/pt_PT/Particulares.html;)
  = https://www.santandertotta.pt/pt_PT/Particulares.html; 
 2.1.2 :075  browser.text_field(:name = usr).set foo
  = nil 
 2.1.2 :076  browser.button(value: 'Login').click
  = [] 
 2.1.2 :077  browser.iframe(id: 'ws').text_field(id: 
 'claveConsultiva').set 'bar'
  = nil 
 2.1.2 :078  browser.iframe(id: 'ws').link(id: 'login_button').click
  = [] 
 2.1.2 :079  


 On Mon, Nov 24, 2014 at 4:36 PM, Alberto Magalhaes aacmag...@gmail.com 
 javascript: wrote:

 Joe,
 Line 10. thanks

 On Mon, Nov 24, 2014 at 10:35 PM, Alberto Magalhaes aacmag...@gmail.com 
 javascript: wrote:

 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:10:in
  
 `locate': unable to locate iframe using {:id=ws, :tag_name=iframe} 
 (Watir::Exception::UnknownFrameException)
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in
  
 `assert_exists'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:31:in
  
 `assert_exists'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:532:in
  
 `locate'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in
  
 `assert_exists'
 from 
 C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/user_editable.rb:11:in
  
 `set'
 from teste_2.rb:8:in `main'
 Exit code: 1

 On Mon, Nov 24, 2014 at 10:30 PM, Joe Fleck joefl...@gmail.com 
 javascript: wrote:

 Alberto,

 What line is this failing on?

 Joe

 On Mon, Nov 24, 2014 at 5:26 PM, Alberto Magalhaes 
 aacmag...@gmail.com javascript: wrote:

 Titus,

 I'm trying this:
 require 'watir-webdriver'
 browser = Watir::Browser.new :chrome
 browser.goto(https://www.santandertotta.pt/pt_PT/Particulares.html;)
 browser.text_field(:name = usr).set foo
 browser.button(:value = Login).click
 usr=Nome%20de%20Utilizador'
 browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').set 'bar'
 browser.iframe(id: 'ws').link(id: 'login_button').click


 On Mon, Nov 24, 2014 at 9:36 PM, Titus Fortner titusf...@gmail.com 
 javascript: wrote:

 This works for me.

 browser = Watir::Browser.new :chrome
 browser.goto '
 https://www.particulares.santandertotta.pt/pagina/indice/0,,276_1_2,00.html?usr=Nome%20de%20Utilizador
 '
 browser.iframe(id: 'ws').text_field(id: 'identificacionUsuario').set 
 'Foo'
 browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').set 'Bar'
 browser.iframe(id: 'ws').link(id: 'login_button').click

 On Mon, Nov 24, 2014 at 3:19 PM, Alberto Magalhães 
 aacmag...@gmail.com javascript: wrote:


 Joe and Titus 

 it's not working.

 I'm trying to access

[wtr-general] Re: page-object and frames

2013-12-03 Thread Justin Ko
You can use the generic element accessor, which is in the form 
element(:name, :tag_name, :identifier = 'value'). For example:

element(:fckeditor, :frame, :id = 'editor')

This would let you do:

fckeditor_element.send_keys(This is my text)

Note that you can also locate the element directly, without the accessor:

page.element(:frame, :id = 'editor').send_keys(This is my text)

- Justin

On Monday, December 2, 2013 9:15:33 AM UTC-5, Dan wrote:

 This doesn't get me a handle to the frame itself.  I'm looking for 
 something like.

 frame(:fckeditor,:id = 'editor') 
 fckeditor_element.send_keys(This is my text)

 On Friday, November 29, 2013 5:44:32 AM UTC-5, QOExcel wrote:

 in_frame(:class = 'share-client-content-iframe') do |frame|
 text_field(:invite, :id = ':p.fakeRecipient', :frame = frame)
 text_area(:hiddeninvite, :id = ':l', :frame = frame)

 среда, 27 ноября 2013 г., 20:07:58 UTC+4 пользователь Dan написал:

 I know this isn't a watir question per se, but I know a lot of members 
 of this group use page object.  I'm trying to send keys directly to a frame 
 using page-object, but the problem is I can't get a handle to just the 
 frame, just elements inside of it?  This is one of those fckeditor kind of 
 things.

 # How do I interact with just the frame itself?

 in_frame(:id = 'blah') do |frame|
 end



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[wtr-general] Re: Error selec_list on modal dialog

2013-11-18 Thread Justin Ko
I created an issue for this - 
https://github.com/watir/watir-classic/issues/64

In the short term, I think the best solution might be to simply monkey 
patch a focus method in for the modal dialog. This would address the 
exception without impacting focusing of elements in the regular part of the 
browser (ie not modal dialog).

require 'watir-classic'
module Watir
  class ModalDialog
def focus
end
  end
end

Justin

On Tuesday, November 5, 2013 2:24:57 AM UTC-5, Stefano wrote:

 Hi, there is the same issue with Ruby 2.0.0 and watir-classic (4.0.1). Any 
 idea?
  
 Stefano


-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[wtr-general] Re: Nokogiri + Watir

2013-09-03 Thread Justin Ko
On Thursday, August 29, 2013 11:18:59 AM UTC-4, Bashir Osman wrote:

 Watir processes the DOM too slow which causes me to over use 'sleep' and 
 'when_present'. I wanted to use Nokogiri to process the DOM then have watir 
 automate that DOM without using Nokogiri syntax. 

 
You could consider using the watir-nokogiri gem 
(http://rubygems.org/gems/watir-nokogiri).

Watir-nokogiri gem is basically a wrapper around Nokogiri using the Watir 
API. It would mean you can get the performance of parsing with Nokogiri 
without having to know the Nokogiri syntax. Unfortunately, at this point, 
there is no automatic integration with the Watir browser (ie you have to 
manually pass the Watir html to the WatirNokogiri parser).

- Justin Ko

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[wtr-general] Re: Any fast ways to parse a table

2013-07-12 Thread Justin Ko
The CheckTableUsingRowArray approach does not seem faster to me. The 
location of the timer excludes the Watir portion of the code, which is 
costly. In particular, the following line adds about 28 seconds for me:

myTableArray = obj.to_a  #Array the table

An alternative approach is to use the Nokogiri gem to parse the table. 
Zeljko had a good post on the topic - 
http://zeljkofilipin.com/watir-nokogiri/ . 

Try the following, which takes about 0.1 seconds:

#myHash is the same ordered hash used in the other approaches:
myHash = { 'col1' = 'Row30 Content1', 'col2' = 'Row30 Content2', 'col3' 
= 'Row30 Content3', 'col4' = 'Row30 Content4', 'col5' = 'Row30 
Content5', 'col6' = 'Row30 Content6', 'col7' = 'Row30 Content7', 'col8' 
= 'Row30 Content8' }
myArray = myHash.values
  
start = Time.now 
obj = ie.table(:id,'table1')
nokogiri = Nokogiri::HTML.parse(obj.html)
nokogiri.css('tr').each_with_index do |tr, i|
if tr.css('td').collect(:text) == myArray
puts Row to click: #{i}
end
end
puts Time to finish: #{Time.now - start}

#Output:
# Row to click 30
# Time to finish: 0.091

- Justin Ko


On Friday, July 12, 2013 5:49:07 PM UTC-4, Super Kevy wrote:

 OK.  I ran a sample and have some benchmarks for a simple table look up

 In the sample below I have a simple table with 30 row of 8 columns.
 The test measure the time to find the matching row (the sample is row 30)
 There are two methods.  One uses if comparisons of the tables columns 
 within the row. The second method intersects the data to find with an array 
 of each row.  The time was quite dramatic.

 Using the If statements the time was about 25 seconds to find matching 
 table row 30
 Using the intersect method for arrray comparisons the table match was 
 immediate (zero seconds)

 Script Code
 ===
 require 'rubygems'
 require 'watir-webdriver'
 #require 'win32ole'
 require 'uri'
 require 'date'

 def Method_OpenBrowser(sURL,sBrowserType) 
   puts '* Method_OpenBrowser' 
   puts ' - Browser type: ' + sBrowserType.to_s 
   puts ' - URL: ' + sURL.to_s
   ie=0
   ie = Watir::Browser.new(sBrowserType) 
   ie.window.maximize()
   ie.goto(sURL) 
   sleep 2
   puts ' - Return ' + ie.to_s
   return ie
 end

 # 
 # Hash values are fetched and compared using ifs with each row column
 # A complete match outputs the time delta
 # 
 def Method_CheckTableUsingIfs(ie,myHash)
   puts '* Method_CheckTableUsingIfs'
   puts ' - # of Column values to match: ' + myHash.length().to_s
   obj = ie.table(:id,'table1').tbody(:id,'tbody1')
   iDataRows = obj.rows.length() - 1
   iRowIndex = 1
   startTime = Time.now
   iDataRows.times do
 if myHash.fetch('col1') == obj.tr(:index = iRowIndex).td(:index = 
 0).text.to_s then 
   if myHash.fetch('col2') == obj.tr(:index = iRowIndex).td(:index = 
 1).text.to_s then 
 if myHash.fetch('col3') == obj.tr(:index = iRowIndex).td(:index 
 = 2).text.to_s then 
   if myHash.fetch('col4') == obj.tr(:index = 
 iRowIndex).td(:index = 3).text.to_s then 
 if myHash.fetch('col5') == obj.tr(:index = 
 iRowIndex).td(:index = 4).text.to_s then 
   if myHash.fetch('col6') == obj.tr(:index = 
 iRowIndex).td(:index = 5).text.to_s then 
 if myHash.fetch('col7') == obj.tr(:index = 
 iRowIndex).td(:index = 6).text.to_s then 
   if myHash.fetch('col8') == obj.tr(:index = 
 iRowIndex).td(:index = 7).text.to_s then 
 puts ' - All columns matched. Return the delta time to 
 main. Click this row: ' + iRowIndex.to_s
 endTime = Time.now - startTime
 puts ' - Time to match: ' + endTime.to_s
 puts ' - Return: ' + endTime.to_s
 STDOUT.flush()
 return endTime.to_s
   end
 end
   end
 end
   end
 end
   end
 end
 iRowIndex = iRowIndex + 1
   end
   puts ' - No Match in table. '
   puts ' - Return: -1'
   return -1
 end


 # 
 # The Hash is converted to an array (array = hash.values). 
 # The array is matched using intersection of the table's row array
 # A complete match outputs the time delta
 # 
 def Method_CheckTableUsingRowArray(ie,myArray)
   puts '* Method_CheckTableUsingRowArray'
   puts ' - # of Column values to match: ' + myArray.length().to_s
   obj = ie.table(:id,'table1').tbody(:id,'tbody1')
   myTableArray = obj.to_a  #Array the table
   puts ' - Table Length (Rows): ' + myTableArray.length().to_s
   iRowIndex=0
   startTime = Time.now
   myTableArray.each do |e|
 case (e  myArray).length()
   when 8
 puts ' - All columns matched

[wtr-general] Re: Watir and Chrome: unit tests give Errno::ECONNREFUSED once in 50 tests

2013-04-19 Thread Justin Ko
Based on the exception, it looks like you are on selenium-webdriver version 
2.29.0. You should probably try upgrading to the latest version, which is 
2.32.1.

Justin


On Thursday, April 18, 2013 5:45:04 AM UTC-4, gu...@dna-7.com wrote:

 Hello,

 I use Watir and the Chrome Webdriver in my unit tests (as end-to-end tests 
 to my website), via Jenkins.
 (i.e. I *require 'watir'* and instantiate use *@browser = 
 Watir::Browser.new :chrome* in the setup method of the testcase class.)

 It works fine, but once in ~40 tests or so I get the following error:
 *Errno::ECONNREFUSED: No connection could be made because the target 
 machine actively refused it. - connect(2)*

 Now, if it was happening all of the time - that's one thing. But since 
 this is an alternating error, quite rare yet occurring several times a day 
 (since I run them every 10 minutes).

 Any ideas?

 Best,
 g.

 Below is the error. I did not include the code for the tests since I get 
 it on the instantiation of new browser - *@browser = Watir::Browser.new 
 :chrome* is the problematic line, and besides I don't think the code is 
 the problem since it's working most of the time.

 12:07:39   1) Error:
 12:07:39 test_fill_survey(ReadOnlyTests):
 12:07:39 Errno::ECONNREFUSED: No connection could be made because the 
 target machine actively refused it. - connect(2)
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/default.rb:83:in
  
 `response_for'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/default.rb:39:in
  
 `request'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/common.rb:40:in
  
 `call'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/bridge.rb:615:in
  
 `raw_execute'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/bridge.rb:92:in
  
 `create_session'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/bridge.rb:68:in
  
 `initialize'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/chrome/bridge.rb:29:in
  
 `initialize'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:37:in
  
 `new'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:37:in
  
 `for'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver.rb:67:in
  
 `for'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.2/lib/watir-webdriver/browser.rb:46:in
  
 `initialize'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:16:in
  
 `new'
 12:07:39 
 c:/ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:16:in
  
 `new'
 12:07:39 DNASurveyWebApp/DNASurvey.Test/Watir/EndToEnd.rb:78:in `setup'


-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[wtr-general] Re: How do I get the maxlength for a text_field?

2013-02-13 Thread Justin Ko
In watir-webdriver, you would have to use the attribute_value method:

browser.text_field.attribute_value('maxlength')

Justin


On Tuesday, February 12, 2013 12:51:03 AM UTC-5, Phuoc Can Hua wrote:

 I used to use textField().maxlength in my scripts. Now I've changed it to 
 use 'watir-webdriver'. It doesn't like textField and I had to change it to 
 text_field instead.
 My problem is I can't get text_field().maxlength. It's saying: undefined 
 method.
 How can I get maxlength of text_field?

 Thanks
 Phuoc


-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[wtr-general] Re: watir-classic user agent

2013-01-28 Thread Justin Ko
That same code will work in watir-classic.

The execute_script method exists in watir-classic and navigator.userAgent 
is supported in all major browsers 
(http://www.w3schools.com/jsref/prop_nav_useragent.asp).

- Justin Ko


On Monday, January 28, 2013 11:49:16 AM UTC-5, Dan wrote:

 Is there a good way to get the user agent using the watir-classic gem? 
  With webdriver I use something like b.execute_script(return 
 navigator.userAgent), but that's not going to work with watir-classic.

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [wtr-general] Failed 'assert' statement doesn't get rescued

2012-12-19 Thread Justin Ko
Since you are using Ruby 1.9.3, the line

require 'test/unit'

Will require the Minitest gem. In contrast, in Ruby 1.8.7, this would 
include the Test::Unit gem.

If you do a rescue without a type specified, the default type is 
StandardError, which is a subclass of Exception. 
In Minitest, when an assertion fails, a MiniTest::Assertion is thrown. This 
is a subclass of Exception rather than StandardError. Hence it will not be 
caught by the rescue.

You need to add the exception type:

require 'test/unit'
class TC_Sample  Test::Unit::TestCase
  def test_01
begin
  assert(false)
rescue MiniTest::Assertion
  p Batdog to the Rescue!
end
  end
end

- Justin Ko


On Wednesday, December 19, 2012 10:35:26 AM UTC-5, captin wrote:

 Thank you for your reply and for taking the time to assist me. As I stated 
 in my OP, I'm new to watir. I've come across RSpec and Cucumber many times 
 as I've been learning but have yet to dig into them. I will most likely be 
 evaluating those in the near future, but I wanted to understand the 
 fundamentals first and maybe build my own basic test framework.
  
 I wasn't able to get your simplified example to work for me. Here's my 
 ruby version:
  
 ruby 1.9.3p327 (2012-11-10) [i386-mingw32]
  
 When I run your unaltered example, it gives the following output:
  
 Run options:
 # Running tests:
 E
 Finished tests in 0.002000s, 500. tests/s, 500. assertions/s.
   1) Error:
 test_01(TC_Sample):
 NameError: uninitialized constant Test::Unit::AssertionFailedError
 test1.rb:22:in `rescue in test_01'
 test1.rb:20:in `test_01'
 1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
  
 When I comment out the Test::Unit::AssertionFailedError so the rescue is 
 simplified, it seems to skip the rescue just like my original example did:
  
 Run options:
 # Running tests:
 F
 Finished tests in 0.002000s, 500. tests/s, 500. assertions/s.
   1) Failure:
 test_01(TC_Sample) [test1.rb:21]:
 Failed assertion, no message given.
 1 tests, 1 assertions, 1 failures, 0 errors, 0 skips
  
 Do you think the difference in behavior is due to the Ruby versions? Or 
 maybe due to differences in our gem versions? Here's my gem list:
  
 *** LOCAL GEMS ***
 addressable (2.3.2)
 bigdecimal (1.1.0)
 builder (3.1.4)
 childprocess (0.3.6)
 commonwatir (4.0.0)
 ffi (1.2.0 x86-mingw32)
 firewatir (1.9.4)
 hoe (3.3.1)
 io-console (0.3)
 json (1.5.4)
 libwebsocket (0.1.6.1)
 logger (1.2.8)
 mini_magick (3.2.1)
 minitest (2.5.1)
 multi_json (1.3.7)
 nokogiri (1.5.5 x86-mingw32)
 rake (0.9.2.2)
 rautomation (0.7.3)
 rdoc (3.9.4)
 rubyzip (0.9.9)
 s4t-utils (1.0.4)
 selenium-webdriver (2.26.0)
 subexec (0.0.4)
 test-unit (2.5.3)
 user-choices (1.1.6.1)
 watir (4.0.2 x86-mingw32)
 watir-classic (3.3.0)
 watir-webdriver (0.6.1)
 websocket (1.0.4)
 win32-api (1.4.8 x86-mingw32)
 win32-process (0.7.0)
 win32screenshot (1.0.7)
 windows-api (0.4.2)
 windows-pr (1.2.2)
 xml-simple (1.1.2)
  
 Thanks again for your help.
  
 Captin

 On Wednesday, December 19, 2012 5:15:07 AM UTC-6, Željko Filipin wrote:
  

  Rescuing exceptions so you can log the error message or take a screen 
 shot is the wrong way to do it. My test/unit-fu is pretty rusty, but you 
 should be able to create custom formatter (at least that is how I would do 
 it in RSpec or Cucumber). Is there a reason you are using test/unit instead 
 of RSpec or Cucumber?

 That said, I have simplified the code that you have posted a bit, and it 
 rescues the exception on my machine.

  require 'test/unit'
 class TC_Sample  Test::Unit::TestCase
   def test_01
 begin
   assert(false)
 rescue Test::Unit::AssertionFailedError
   puts Batdog to the Rescue!
 end
   end
 end

 The script rescues the exception if I use just rescue or rescue 
 Test::Unit::AssertionFailedError.

  $ ruby test.rb 
 Loaded suite test
 Started
 Batdog to the Rescue!
 .
 Finished in 0.017473 seconds.

 1 tests, 1 assertions, 0 failures, 0 errors

  $ ruby -v
 ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]

 What version of Ruby are you using? 

 Željko
 --
 https://leanpub.com/watirbook 



-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Isn't .exists? a boolean method?

2012-12-12 Thread Justin Ko
Are you using Firefox? I had this problem after updating Firefox to version 
17.

Upgrading to the latest version of selenium-webdriver (2.27.2) fixed the 
issue for me.

Justin


On Wednesday, December 12, 2012 12:15:56 PM UTC-5, Abe Heward wrote:

 Note that I am using Watir-webdriver 0.6.2

 On Wednesday, December 12, 2012 10:12:28 AM UTC-7, Abe Heward wrote:

 I appear to be misunderstanding something fundamental...

 Assume my page does not contain a span with a class of welcome...

 Given that, if I have this line in my Watir code:

 @browser.span(class: welcome).exist?

 ...should that not immediately return a *false*?

 Why would this ever return a Timeout::Error? instead of *false*?

 All I'm getting, though, is the timeout error, which makes the .exists? 
 method rather useless to me.

 What am I doing wrong, here?



-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] undefined method `exists?' for link (PageObject gem)

2012-11-02 Thread Justin Ko
The page object gem automatically creates a method for checking existence - 
see the docs 
http://rubydoc.info/github/cheezy/page-object/master/PageObject/Accessors#link-instance_method.

So for:

link(:signout, :text = 'Sign Out')

There should be able to do:

signout?

- Justin Ko


On Friday, November 2, 2012 4:46:31 AM UTC-4, Željko Filipin wrote:

 Try this:

 Then /^I should have access to my account$/ do
   on(LoginPage).signout_element.should exist
 end

 Explanation:

 on(LoginPage).signout # clicks the link
 on(LoginPage).signout_element # returns the link

 More information:

 https://github.com/cheezy/page-object/wiki/Elements

 Željko
 --
 filipin.eu


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: watir-classic Element#style vs watir-webdriver Element#style

2012-10-26 Thread Justin Ko
I also ran into this yesterday. There was talk in 
http://rubyforge.org/pipermail/wtr-development/2012-February/003541.html 
about fixing watir-classic to be the same. Though it looks like it was not 
implemented.

I think all you would need to do for watir-classic is change the style 
method to:

# return the css style as a string
def style(property = nil)
assert_exists
if property
ole_object.currentStyle.send(property)
else
ole_object.style.cssText
end
end

It would make watir-classic similar to watir-webdriver. Though I think you 
would get different formats for some of the properties (example 'color').

Justin Ko


On Friday, October 26, 2012 6:26:53 AM UTC-4, Connor C wrote:

 Hey Jarmo or whoever else can help :), 

 In the latest wair-classic the Element#style() method works as follows

# return the css style as a string
 def style
   assert_exists
   ole_object.style.cssText
 end


 but it still doesn't behave like the webdriver version (which takes a 
 property argument).

def style(property = nil)
   if property
 assert_exists
 @element.style property
   else
 attribute_value(style).to_s.strip
   end
 end


  It would be really useful if the watir-classic behaviour matched the web 
 driver version. Are there any plans to update this in the future or is 
 there a specfic reason they are different? 

 Thanks thanks thanks,
 Connor


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Win32-process error Installation Watir 2.0.4

2012-10-19 Thread Justin Ko
When you try to install watir 2.0.4, it will grab the latest version of the 
win32-process gem (and other dependencies) unless you already have one 
installed. Currently the win32-process gem is at version 0.7.0, which you 
do not want. So the solution is to manually install a prior version of the 
win32-process gem. I believe watir 2.0.4 was originally using win32-process 
0.5.5, though I think you could use 0.6.6 as well.

I was able to get Watir 2.0.4 to install successfully (ie could launch and 
close an IE browser) from a fresh Ruby 1.8.7 install by doing:

gem install win32-process -v 0.5.5
gem install watir -v 2.0.4

- Justin


On Thursday, October 18, 2012 9:55:08 AM UTC-4, Shryan wrote:

 So previously on my old machine I was using Ruby 1.8.7 in conjunction with 
 Watir 2.0.4. I recently inherited a new system. I am trying to configure my 
 same set up on this PC now. However, I install Ruby 1.8.7 and then try to 
 install a specific version of Watir. watir -v 2.0.4

 When I do this though it begins to install and then fails. It says that 
 win32-process requires ruby 1.9.2. If I upgrade my Ruby library, there are 
 a lot of process changes that have to take place in order to get he scripts 
 functional again. (I have checked). 

 Does anybody have a solution on how to get Ruby 1.8.7 with Watir 2.0.4 
 reinstalled. I am not sure why it was working on my other system and will 
 not on this one.

 Thank you, any help is appreciated.


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Unable to select item from selectlist on watir-classic 3.2: SystemStackError: stack level too deep

2012-10-19 Thread Justin Ko
To reproduce the SystemStackError error, you can use the w3schools page:

require 'watir-classic'
browser = Watir::Browser.new
browser.goto('http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select')
browser.frame(:name, 'view').select_list.select('Saab')

Or if you want to do it locally, you can create a page with an iframe and 
select list:

main.htm:

html
body
iframe name=view src=frame.htm
/body
/html

frame.htm:

html
body
select
option value=volvoVolvo/option
option value=saabSaab/option
option value=opelOpel/option
option value=audiAudi/option
/select
/body
/html

Note: The problem can be seen with iframes as well as framesets.

Hope that helps.

- Justin

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com