Page MenuHomePhabricator

Move user agent assignment to Ruby gem
Closed, ResolvedPublic

Description

Three repos (Echo, Flow, MobileFrontend) are using this step:

Given(/^I am using user agent "(.+)"$/) do |user_agent|
  @user_agent = user_agent
  @browser = browser(test_name(@scenario), {user_agent: user_agent})
  $session_id = @browser.driver.instance_variable_get(:@bridge).session_id
end

and doing that properly requires the @custom_browser tag.

We should move this code into the Ruby gem so it is not repeated among 3 repos.

Also, more repos will probably be testing no-javascript mode in the future, so this would likely see even more re-use.

Finally, the shared code should throw an error if BROWSER is anything other than Firefox

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:55 AM
bzimport set Reference to bz71531.
bzimport added a subscriber: Unknown Object (MLST).

We should try to name the step to be clearer to its intention. What about "my browser doesn't support JavaScript", or "I have JavaScript disabled"?

The environment variable browser_user_agent is supported by Chrome and Firefox in MW-Selenium 1.x. Perhaps we can provide an additional browser factory method to allow for explicit configuration overrides at runtime, looking something like:

Given(/^I have JavaScript disabled$/) do
  browser_factory.override(:browser_user_agent, "some JS-less user agent string")
end

Any updates on this? @dduval that works for me.

dduvall raised the priority of this task from Low to High.Jun 4 2015, 10:40 PM

No updates, but let's bump the priority and move it up in TODO.

Change 216866 had a related patch set uploaded (by Dduvall):
Allow explicit configuration overrides at runtime

https://gerrit.wikimedia.org/r/216866

Change 216866 merged by jenkins-bot:
Allow explicit configuration overrides at runtime

https://gerrit.wikimedia.org/r/216866

hashar added a subscriber: hashar.

Merged in would be released in 1.2.1 or 1.3.0