Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove the log of ie web driver?

I am using watir-webdriver + ruby + win7 to test same pages. and I would get these logs while I start the ie explorer by using watir-webdriver:

Started InternetExplorerDriver server (32-bit)
2.32.3.0
Listening on port 5555

are there any methods to remove these logs? any help would be appreciated!

like image 661
Mark Avatar asked Nov 25 '25 05:11

Mark


1 Answers

IEDriver supports a --silent flag that suppresses diagnostic output when the server is started.

Unfortunately, at least to my knowledge, it is not configurable when creating a browser instance. Instead, you need to directly modify the Selenium::Webdriver::IE::Server class' server_args method. You can modify the lib\selenium\webdriver\ie\server.rb file directly, but it is probably easier to monkey patch.

To monkey patch the silent flag, add the following to your code some point after requiring watir-webdriver (ie selenium-webdriver) but before opening the browser.

class Selenium::WebDriver::IE::Server
    old_server_args = instance_method(:server_args)
    define_method(:server_args) do
        old_server_args.bind(self).() << "--silent"
    end       
end

For example, the following will no longer log any messages.

require 'watir-webdriver'

class Selenium::WebDriver::IE::Server
    old_server_args = instance_method(:server_args)
    define_method(:server_args) do
        old_server_args.bind(self).() << "--silent"
    end       
end

b = Watir::Browser.new :ie
like image 93
Justin Ko Avatar answered Nov 27 '25 19:11

Justin Ko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!