Reputation: 882
How do I force my browser to come up on the monitor opposite Rubymine in a dual monitor setup?
I am trying to test/debug Feature Scenarios. My tool-set is RubyMine, Ruby, watir, page-object-gem, and Cucumber. I have a dual monitor setup, but the browser always comes up on the same monitor as Rubymine.
I made some changes to my hooks.rb file:
Before do
@browser = Watir::Browser.new :firefox
@browser.window.move_to(1985,24)
@browser.window.maximize
puts " Browser Position " + @browser.window.position.to_s
end
After do
@browser.close
end
This is a very clunky solution. It always comes up on the same monitor as rubymine then moves. I had to hard-code position to use 2nd monitor, so it probably won't work on a different dual-monitor setup.
Question:
Can you suggest a way to implement the following and where would it go?
If(dual_monitor) then browser.move.window_to(other_monitor)
Upvotes: 2
Views: 334
Reputation: 115
Since I write tests at home and in the office and I have dual monitors in both places, and they are different sizes, I just use an environment variable:
if ENV['MOVE_BROWSER'] =~ /home/i
browser.window.move_to(2080,0)
elsif ENV['MOVE_BROWSER'] =~ /office/i
browser.window.move_to(-2562, -600)
end
screen_width = browser.execute_script("return screen.width;")
screen_height = browser.execute_script("return screen.height;")
browser.driver.manage.window.resize_to(screen_width,screen_height)
This also ensures other testers are not affected by my preferences. I use Sublime on the largest available screen, and then have the browser on the other.
Upvotes: 1