2
votes

I'm using Watir WebDriver in Chrome.

I'm testing a left/right list box. Items selected in the left box can be moved to the right by clicking ">". Similarly, items in the right list box can be moved to the left.

I want to emulate a user highlighting the first line, then highlighting the last line and pressing Shift+click

I'm trying a piece of code that I found here:

http://watirmelon.com/2011/07/19/sending-special-keys-to-watir-webdriver/

Here's my code:

# select first item in list
@browser.select_list(:id, "Attendees").option(:text => 'J. Bloggs').click
# select last item in list    
@browser.select_list(:id, "Attendees").option(:text => 'J. Doe').click(:shift)
@browser.button(:value,">").click
# next line is executed
puts 'Hi!'

The first item is highlighted. After that, the script runs silently past the script, and executes the puts.

The second line is not highlighted. Nothing is transferred from left to right.

1

1 Answers

1
votes

This issue was a false alarm.

My specification for the button was not unique:

@browser.button(:value,">").click

An earlier button was being silently clicked.

My apologies.