
| Key: |
WTR-182
|
| Type: |
New Feature
|
| Status: |
Open
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Manish Sapariya
|
| Votes: |
2
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
Watir
Created: 23/Oct/07 11:53 PM
Updated: 24/Nov/08 02:04 PM
|
|
| Component/s: |
"Wait"
|
| Affects Version/s: |
None
|
| Fix Version/s: |
Soon
|
|
|
Original Estimate:
|
Unknown
|
Remaining Estimate:
|
Unknown
|
Time Spent:
|
Unknown
|
|
Issue Links:
|
Relationship
|
|
|
|
This issue Relates to:
|
|
WTR-185
Add a new method for "set" - that is...
|
|
|
|
|
|
|
The command that I need to execute prior to a "Windows Internet
> Explorer" window launching is to "set" a radio button.
>
> $browser.radio(:id, "xxxxx").set
>
> I know that when a button is clicked prior to a pop-up window...that a
> 'click_no_wait' method is required. Is there something similar for the
> 'set' function? I tried, "set_no_wait" and received an: "undefined
> method 'set_no_wait'"
>
> My app is hanging at this spot.
>
> Thanks,
> Lauren
>
Lauren,
This is a reasonable request. Could you please open a Jira ticket for it?
Bret
-
Along that same line, do you by chance know if there is a similar no_wait method, but for Wscript? I am trying to export from my app to an Excel spreadsheet. A modal File Download window is triggered, which I drive with Wscript, and both processes (IE and Excel) hang when I do wsh.SendKeys "{ENTER}" to open Excel. Then I can't seem to close either of the windows after that either. Thanks!
--Randy
Also,
When dealing with the security dialog box that pops up when
doing something like
ie.goto("myinernal.app.com")
which redirects to https:// and the certificate is not signed,
we have to deal with security dialog box. In this case
ie.goto_no_wait()
would be really useful.
I need to deal with security dialog box almost always while
testing apps that switch to https interface.
Thanks,
Manish
|
|
Description
|
The command that I need to execute prior to a "Windows Internet
> Explorer" window launching is to "set" a radio button.
>
> $browser.radio(:id, "xxxxx").set
>
> I know that when a button is clicked prior to a pop-up window...that a
> 'click_no_wait' method is required. Is there something similar for the
> 'set' function? I tried, "set_no_wait" and received an: "undefined
> method 'set_no_wait'"
>
> My app is hanging at this spot.
>
> Thanks,
> Lauren
>
Lauren,
This is a reasonable request. Could you please open a Jira ticket for it?
Bret
-
Along that same line, do you by chance know if there is a similar no_wait method, but for Wscript? I am trying to export from my app to an Excel spreadsheet. A modal File Download window is triggered, which I drive with Wscript, and both processes (IE and Excel) hang when I do wsh.SendKeys "{ENTER}" to open Excel. Then I can't seem to close either of the windows after that either. Thanks!
--Randy
Also,
When dealing with the security dialog box that pops up when
doing something like
ie.goto("myinernal.app.com")
which redirects to https:// and the certificate is not signed,
we have to deal with security dialog box. In this case
ie.goto_no_wait()
would be really useful.
I need to deal with security dialog box almost always while
testing apps that switch to https interface.
Thanks,
Manish
|
Show » |
|
I encountered the same problems when an ie.select_list(:name,"a-select-list").select("an-option") call elicited a popup that I could not handle because the internal Watir code was doing a "@container.wait" call.
Fortunately, Ruby's "singleton class" capability allows us to dynamically override object methods and so I was able to implement a workaround by overriding the Watir SelectList.select method (from input_elements.rb) and the Element.fire_event method (from elements.rb) by adding an optional "wait" flag (default=true) to the problem methods as shown below:
...
# let select_list_causing_popup represent a Watir select_list that might/will
# cause a popup that you must handle immediately
select_list_causing_popup = ie.select_list(:name,"aselectlist")
# dynamically override the Watir methods for .fire_event and .select
# to create optionally "asynchronous" versions
class << select_list_causing_popup
# From Watir:element.rb
def fire_event(event,wait=true) # add an optional "wait" flag to control waiting
assert_enabled
highlight(:set)
ole_object.fireEvent(event)
@container.wait if wait # waiting is now optional
highlight(:clear)
end
# From Watir:input_elements.rb
def select(item,wait=true) # add an optional "wait" flag to control waiting
select_item_in_select_list(:text, item, wait)
end
def select_item_in_select_list(attribute, value, wait=true)
assert_exists
highlight(:set)
doBreak = false
@container.log "Setting box #{@o.name} to #{attribute} #{value} "
@o.each do |option| # items in the list
if value.matches(option.invoke(attribute.to_s))
if option.selected
doBreak = true
break
else
option.selected = true
@o.fireEvent("onChange")
@container.wait if wait # waiting is now optional
doBreak = true
break
end
end
end
unless doBreak
raise NoValueFoundException,
"No option with #{attribute.to_s} of #{value} in this select element"
end
highlight(:clear)
end
end
# select the option
select_list_causing_popup.option("anoption",false) # call YOUR asynchronous version of .option()
select_list_causing_popup.fire_event("onclick",false) # call YOUR asynchronous version of .fire_event()
# control returns here immediately so you can handle the popup-dialog
...
This technique appears to have the following advantages:
+ You can selectively employ it where you need it.
+ The default calling sequences for the methods remain unchanged as the "wait" flag is optional.
+ You can apply this technique to other Watir methods "X" that require a "X_no_wait" variant.
The primary disadvantage is that the code for the overriden methods may have to change if their corresponding code within Watir changes with a new release.
Anyway, I hope this helps.
Bob