Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract pid of browser launched by Selenium WebDriver in Ruby

Tags:

ruby

selenium

Does anyone know how to get the process id of the browser launched by Selenium WebDriver from the Ruby script that runs the WebDriver?

like image 579
jeffcook2150 Avatar asked Jan 18 '23 15:01

jeffcook2150


1 Answers

The answer of Ben did not work for me, I had to adjust it to the following:

driver = Selenium::WebDriver.for :chrome

bridge = driver.instance_variable_get(:@bridge)
service = bridge.instance_variable_get(:@service)
process = service.instance_variable_get(:@process)
process.pid
# => 22656
like image 182
sougonde Avatar answered Mar 29 '23 09:03

sougonde