aldrien.h
aldrien.h

Reputation: 3635

How to maximize browser in minitest-rails selenium test?

I'm doing minitest-rails with feature testing.

I noticed that the browser (i'm using chrome) is NOT in full width.

Where or how can I set it in my configuration file?

Currently I have installed the following gems:

  selenium-webdriver (2.53.4)
  chromedriver-helper (1.0.0)
  capybara (2.8.1, 2.7.1)
  capybara-screenshot (1.0.13)
  minitest-capybara (0.8.2)
  minitest-rails-capybara (2.1.2)

Please help!

Upvotes: 2

Views: 578

Answers (2)

user1032752
user1032752

Reputation: 881

This also worked for me and is set once in the ApplicationTestCase class.

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  Capybara.register_driver :selenium_remote_chrome do |app|
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_argument('--start-maximized')

    Capybara::Selenium::Driver.new(
      app,
      browser: :remote,
      url: CHROMEDRIVER_URL,
      desired_capabilities: :chrome,
      options: options
    )
  end
end

Upvotes: 0

aldrien.h
aldrien.h

Reputation: 3635

SOLVED !!!

Finally I found the solution:

There are two(2) options setting the browser's width and height.

1st: Set the specific size, ex:

page.driver.browser.manage.window.resize_to(1366,768)

2nd: Make it full size or maximize it, ex:

page.driver.browser.manage.window.maximize

Hope this help others :)

Upvotes: 6

Related Questions