[Feature Request] Change screensize while running System Test

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Feature Request] Change screensize while running System Test

Pierre Hedkvist
Hi,

I have a feature request regarding the screen size used by System test. Currently you initiate the screen size inside 

/test/application_system_test_case.rb
require "test_helper"


class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by
:selenium, using: :chrome, screen_size: [1400, 1400]
end



What if you have a mobile friendly web application, and the app is displayed differently depending on the screen size.
Could it be possible to change the size of the browser while running the test suite, this could be handy, because nobody wants to change a config files in between tests? 

I have found that you can change the screen size using capybara like this. I have tested this myself, and works fine. There must be similar solutions using poltergeist and webkit as well.
Capybara.current_session.driver.browser.manage.window.resize_to(400, 400)

My initial idea would be to somehow specify in your test, what screen size you would like for your tests, and change it depending. What do you think about this?

If there is anything else that need to be done in regards to System Test, I am open for suggestion, I am eager to contribute. :) 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Request] Change screensize while running System Test

Eileen M. Uchitelle
Now that I'm on a computer I can repost my twitter reply in case anyone comes across this and wonders the same thing. Ref https://twitter.com/PierreHedkvist/status/931139262426296321

Adding a feature to set the screen size per-test won't work because the drivers are initialized when the test class is initialized and not the test itself. That said, generally, I think you'd be testing system tests for mobile in their own test class or perhaps in a group of tests so I suggest writing something like this:

```
# test/application_system_test_case.rb

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :chrome, screen_size: [ 1400, 1400 ]
end

class MobileSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :chrome, screen_size: [ 400, 800 ], options: { whatever other options you need for mobile to work }
end
```

In this case your mobile tests would inherit from the mobile test class and the rest of your tests would inherit from the other one.

On Wednesday, November 15, 2017 at 6:46:39 AM UTC-5, Pierre Hedkvist wrote:
Hi,

I have a feature request regarding the screen size used by System test. Currently you initiate the screen size inside 

/test/application_system_test_case.rb
require "test_helper"


class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by
:selenium, using: :chrome, screen_size: [1400, 1400]
end



What if you have a mobile friendly web application, and the app is displayed differently depending on the screen size.
Could it be possible to change the size of the browser while running the test suite, this could be handy, because nobody wants to change a config files in between tests? 

I have found that you can change the screen size using capybara like this. I have tested this myself, and works fine. There must be similar solutions using poltergeist and webkit as well.
Capybara.current_session.driver.browser.manage.window.resize_to(400, 400)

My initial idea would be to somehow specify in your test, what screen size you would like for your tests, and change it depending. What do you think about this?

If there is anything else that need to be done in regards to System Test, I am open for suggestion, I am eager to contribute. :) 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.