Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium tests in Firefox #1168

Merged
merged 43 commits into from
Feb 25, 2017
Merged

Selenium tests in Firefox #1168

merged 43 commits into from
Feb 25, 2017

Conversation

cowlicks
Copy link
Contributor

@cowlicks cowlicks commented Jan 28, 2017

Currently the support for FireFoxe's WebExtensions in selenium is lacking. As of today there is no way to install a WebExtension #1181 with selenium, or geckodriver #211. Fortunately there is a way to install them using web-ext.

The strategy in this PR is to get selenium working for us:

  • install the extension and start firefox with web-ext
  • attach geckodriver to the running instance of firefox
  • connect selenium.webdirver.Remote to geckodriver
  • refactor the selenium tests to be browser agnostic
  • get this working with xvfb so we can run it on travis
  • run on travis

closes #1009 🎉

I was experimenting with xvfb earlier today, so that step might not be too hard.

Have y'all seen anyone else who has this working yet? This solution is kind of a hack, but it is only temporary until selenium gets up to speed.

self.js = self.driver.execute_script

super(PBSeleniumTest, self).run(result)
if result._excinfo:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a dirty hack to get a nice @repeat_if_failed decorator working. It only works with pytest. It should be removed once the tests are more consistent.

@cowlicks cowlicks changed the title WIP selenium tests in firefox Selenium tests in Firefox Feb 4, 2017
@cowlicks
Copy link
Contributor Author

cowlicks commented Feb 4, 2017

Firefox tests pass! 🎉 🎈

The pbtest.py stuff could be cleaned up some. But this is mostly ready for review.
@cooperq @ghostwords

@cowlicks
Copy link
Contributor Author

cowlicks commented Feb 5, 2017

Green checks! ✓✓✓✓✓✓✓✓✓✓✓✓✓


@pbtest.repeat_if_failed(5)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test now gets re-run if it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now instead of the whole test suite getting re-run for this flaky test, only tests with this decorator get re-run. Which should greatly improve the speed of the travis runs.

get_sc_domains_js = "return JSON.stringify(badger.storage."\
"getBadgerStorageObject('supercookie_domains').getItemClones())"
supercookieDomains = json.loads(self.js(get_sc_domains_js))
return origin in supercookieDomains

@pbtest.repeat_if_failed(5)
def test_should_detect_ls_of_third_party_frame(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also gets re-run.

@@ -42,6 +44,9 @@ def test_page_title(self):
" expected (%s)"
% (self.driver.title, localized_title))


@unittest.skipIf(os.environ.get('BROWSER') == 'firefox',
"selenium move_to is currently broken in firefox")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make an issue to eventually remove this once this PR is merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

@cooperq
Copy link
Contributor

cooperq commented Feb 25, 2017

Wow this is a huge PR and a huge amount of work! I just gave it a first pass and all is looking well so far, I'll take a second pass at it right now.

@cooperq
Copy link
Contributor

cooperq commented Feb 25, 2017

This looks good to me. @ghostwords might want to take a second look, but I'm going to merge for now. Any other fixes can happen in follow pull requests AFAIC.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run selenium tests in firefox and chrome
3 participants