1

On running the following script from http://watir.com/guides/form-example/, I get an error:

# Require the gems we want to use
require 'watir'
require 'webdrivers'
require 'faker'

# Initialize the Browser
browser = Watir::Browser.new

# Navigate to Page
browser.goto 'watir.com/examples/simple_form.html'

# Fill out Text Field Names
browser.text_field(id: 'first_name').set 'Luke'
browser.text_field(id: 'last_name').set 'Perry'

# Use Random Email Address via Faker gem
# Read more about Faker gem here: https://github.com/stympy/faker#readme
random_email = Faker::Internet.email
browser.text_field(id: 'email').set random_email

# Select List:
browser.select(id: 'country').select 'Norway'

# Checkboxes:
browser.checkbox(id: 'interests_cars').click
browser.checkbox(id: 'interests_dentistry').click

# Radio Button:
browser.radio(id: 'newsletter_no').click

# Use RadioSet instead of Radio Button:
browser.radio_set(name: 'newsletter').select('Yes')

# Click Button:
browser.button(id: 'submitButton').click

# Evaluate Results:
browser.p(id: 'name').text == 'Hello Luke Perry,' # => true
browser.p(id: 'newsletter').text == "You will be receiving our newsletter at #{random_email}" # => true
browser.p(id: 'activities').text == 'We hope you continue to enjoy cars, dentistry in Norway' # => true

Here is the error:

DevTools listening on ws://127.0.0.1:61657/devtools/browser/97a9134d-96bb-47f6-83e8-56f09555e71e [8472:12912:0826/150047.561:ERROR:device_event_log_impl.cc(214)] [15:00:47.561] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F) [8472:12912:0826/150047.589:ERROR:device_event_log_impl.cc(214)] [15:00:47.589] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)>

Any ideas for running the script successfully?

Thanks

msjanjua
  • 11
  • 1

1 Answers1

0

Ah, based on the clarification everything is working as intended, there's just some extra noise in the console output based on "Chrome attempting to read properties of USB devices that are currently suspended."

You can safely ignore this message.

Look here for more information: USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection error with ChromeDriver v87 / Chrome v87 using Selenium on Windows10

titusfortner
  • 4,099
  • 2
  • 15
  • 29
  • This is definitely a Chrome issue because I was able to run the script successfully using Firefox and got the expected result. "Response Hello Luke Perry, You will be receiving our newsletter at denae@lockman.info We hope you continue to enjoy cars, dentistry in Norway" . Thanks for your replies! – msjanjua Sep 02 '21 at 15:20
  • @msjanjua I think you should have gotten the same result on the page in Chrome, just with extra output in stdout? Or is it exiting the code early? – titusfortner Sep 02 '21 at 19:27
  • It exits the code early and closes the page. In Firefox, the page stays open with the expected results. – msjanjua Sep 02 '21 at 21:03
  • ok, that's a little different. Can you set $DEBUG=true at the beginning, put the result in https://gist.github.com/ and reply with a link? – titusfortner Sep 03 '21 at 14:47
  • I put $DEBUG=true at the very beginning of my script and got these results: https://gist.github.com/msjanjua/1858f6f068df280414378a743dd9709c Let me know if this is what you were looking for. – msjanjua Sep 04 '21 at 02:32
  • Ah, ok. The logs show that the values expected from the results page showed up. But when the ruby program completes it quits the driver, and when the driver quits it closes the browser. If you copy the lines in irb, you'll see the results, or you can put a `sleep(10)` at the end and see it for 10 seconds before it goes away. – titusfortner Sep 04 '21 at 03:34
  • Yes, that worked! I put sleep(10) at the end of my script and the browser stayed open for ten seconds. I will ignore the error messages about "a device attached to the system is not functioning". Thanks. – msjanjua Sep 06 '21 at 15:54