Hi
I am using Cucumber and watir-webdriver to write automated tests for my
application. My objective is to clear the default selected "ADD" and "CHG"
options in the following multi select list and then re-select the ADD
option.
*<select name="actions_arr" id="actions_arr" style="width: 190px; height:
110px;" multiple="multiple">
<option value="Any">
<option value="CHG">
<option value="ADD">
<input name="_actions_arr" type="hidden" value="1"/>*
I have written the following ruby function (including some diagnostic
debug print commands) to clear the select list. In this case the
variable *action_type* = ADD. Issue is that when I run the
browser in headless mode I cannot clear the selected options and I get a
watir exception saying that the list is not a multi select list even
htouhg it really is. However if I drive the app using a local instance
of the IE8 browser, the select list is recognised as a multi select list
and I can clear the options getting the expected results.
*def set_action_type(action_type)
s = @browser.div(:id => 'tabs').frame(:id => 'container').div(:id =>
'sidebar').select_list(:id => 'actions_arr')
puts "Is the combo list visible?"
puts s.visible?
puts "is the list a multi-select list?"
puts s.multiple?
s.clear
puts "Has the ADD option been selected?"
puts s.selected?action_type
puts "Has the CHG option been selected?"
puts s.selected? 'CHG'
puts s.selected_options
end*1) When driving the application using a headless browser I get the
following output:
*Is** the combo list visible?
true
is the list a multi-select list?
false
Watir::Exception::Error: you can only clear multi-selects
./features/step_definitions/atom_steps.rb:43:in `set_action_type'
./features/step_definitions/atom_steps.rb:169:in `/^I select the "(.*?)" action
type$/'
E:\ATOM_TEST\AcceptanceTest\atom\features\filtering.feature:10:in `And I select
the "ADD" action type'
1 scenario (1 failed)
5 steps (1 failed, 4 passed)
0m32.188s
Process finished with exit code 1 *
2) When driving a local instance of the IE8 browser I get the following
output which is correct (ignoring the scenario fail message as all test
steps actually pass):
*Is the combo list visible?
true
is the list a multi-select list?
true
Has the ADD option been selected?
false
Has the CHG option been selected?
false
[]
1 scenario (1 failed)
5 steps (5 passed)
2m1.766s
Process finished with exit code 1*
The question I have is
1. How can I get the above multi-select list test to pass when running
in headless browser mode so that I can clear the options in the select_list
using *s.clear* ?
2. Is there any other workarounds ?
In regards to 1) I have also tried creating a simple HTML page containing
only a multiselect list and launching this page in my browser however
*s.multiple?* still returns *false*
In regards to 2) I'm experimenting with trying to send CONTROL and mouse
click select commands using the actionbuilder class in selenium webdriver
to simulate clearing the selected options as a user would do through the UI.
Please note the below code I use that launches the browser in headless mode:
*require 'watir-webdriver'
require 'selenium/server'
include Selenium
Before do
@server = Selenium::Server.new("selenium-server-standalone-2.0b1.jar",
:background => true)
@server.start # run your tests
capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled =>
true)
@browser = Watir::Browser.new(:remote, :url => 'http://127.0.0.1:4444/wd/hub',
:desired_capabilities => capabilities)
#Uncomment the below line and comment out the above lines if you don't want to
run in headless mode
#@browser = Watir::Browser.new :ie
end
After do
@browser.link(:text => 'Logout').click
@browser.close
@server.stop
end *
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.