mediawiki-extensions-Echo/tests/browser/features/step_definition/no_javascript.rb
Bartosz Dziewoński 0d23ba8bbe Fix browser tests
Some browser tests were broken by 945fccf009.
The badge element is now technically rendered offscreen, with only the
:before and :after pseudoelements being onscreen. Because of this, Selenium
thinks that the badges are invisible, and this breaks various things in
totally unexpected ways.

* article_page.rb: Store references to the parent <li> elements of badges.
  This might not be necessary but I don't know how to access them otherwise.
* badge_steps.rb: When clicking the badges, click the parent <li> element
  rather than the not-really-invisible <a>. Effectively, the <a> gets
  clicked anyway, since they overlap.
* no_javascript.feature/no_javascript.rb: Wait for page load before
  checking that we're on the right page. The wait is no longer
  implicit, since Selenium thinks we're clicking the <li> rather than
  <a> (links are special-cased).
* notification_steps.rb:
  * Check whether the badges exist on the page, rather than whether they
    are visible.
  * Use a weird hack to read badge text. Apparently you can't read the text
    of elements that Selenium thinks are invisible.
    http://stackoverflow.com/questions/20888592/gettext-method-of-selenium-chrome-driver-sometimes-returns-an-empty-string

Bug: T161941
Change-Id: Ic6bcd1088249109e49a47cc9007e6ee002d3d8ba
2017-04-19 22:27:02 +02:00

22 lines
865 B
Ruby

# This test has no javascript
# Therefore this test has no AJAX
# Therefore it should run without any "when_present" clauses
# If you need a "when_present" to make the test run, that is a bug
Given(/^I am using a nojs browser$/) do
# The following user-agent string contains:
# SymbianOS: for RL to NOT load the modern experience
# SMART-TV-SamsungBrowser: to bypass mobile-frontend and stay on the desktop site
browser_factory.override(browser_user_agent: 'SymbianOS,SMART-TV-SamsungBrowser')
end
Given(/^I wait for the page to load$/) do
# Wait for the page to load. We're technically clicking the <li> rather than <a>,
# so the special-case implicit wait after clicking links doesn't kick in.
browser.wait
end
Given(/^I am on Special Notifications page$/) do
expect(on(SpecialNotificationsPage).firstHeading).to match('Notifications')
end