1

I am using Selenium 4 with Ruby and I'm trying to capture the Network activity, but I can't figure out how to use the libraries and haven't found anything related to this for Ruby.

So what I did is:

  • I added the DevTool gem in the Gemfile: gem 'selenium-devtools', '~> 0.91.1'
  • I the code I'm trying this:
devtools = browser.devtools
network = Selenium::DevTools::V91::Network.new(devtools)
network.enable

but it doesn't seem to work.

When debugging I see something strange: on creating the DevTools object there seems to be an exception at the socket method:

Unfortunately I can't figure out why this happens and didn't find anything about this. I tried to force into the .new method which fails somewhere but it doesn't take me anywhere.

Have you stumbled upon something similar or does anyone have some advice on how to properly use the DevTools in Ruby?

voxobscuro
  • 2,132
  • 1
  • 21
  • 45

1 Answers1

0

I haven't used Selenium 4 DevTools, but there is another way you can incorporate this.

To access DevTools, you need to first mention them in your YML file in Ruby. Something like this

chrome:
  switches:
    - auto-open-devtools-for-tabs
  prefs:
    download:
        default_directory: downloads/
    devtools:
        preferences:
            panel-selectedTab: '"network"'

Similarly, if you want to open Console tab you can change from network to console tab.

Also if you want to record the content you can try this particular gem in Ruby which helps to screen record test cases in Ruby Screenrecord

Lux
  • 73
  • 9