Commit b69a4dc6 authored by intrigeri's avatar intrigeri

Test suite: make the "[…] has loaded in the Tor Browser" step more robust (refs: #11592)

For some reason, sometimes the JavaScript that turns "Trying a testing version
of Tails" into "Tails" does not do its job. Waiting more does not help.
This seems to be a minor bug in Tor Browser or our website.

This is the primary cause of fragility of our test suite these days.

Given the benefit of getting more useful feedback from CI greatly outweighs
measuring how often that bug happens, and the scenarios that use this steps are
primarily about something else anyway, let's support both pre-JS and
post-JS titles.
parent 9f57027e
......@@ -109,9 +109,11 @@ When /^I open the address "([^"]*)" in the (.*)$/ do |address, browser|
end
end
# This step is limited to the Tor Browser due to #7502 since dogtail
# uses the same interface.
Then /^"([^"]+)" has loaded in the Tor Browser$/ do |title|
def page_has_loaded_in_the_Tor_Browser(page_titles, language)
if page_titles.class == String
page_titles = [ page_titles ]
end
assert_equal(Array, page_titles.class)
if @language == 'German'
browser_name = 'Tor-Browser'
reload_action = 'Neu laden'
......@@ -119,13 +121,24 @@ Then /^"([^"]+)" has loaded in the Tor Browser$/ do |title|
browser_name = 'Tor Browser'
reload_action = 'Reload'
end
expected_title = "#{title} - #{browser_name}"
try_for(60) { @torbrowser.child?(expected_title, roleName: 'frame') }
# The 'Reload' button (graphically shown as a looping arrow)
# is only shown when a page has loaded, so once we see the
# expected title *and* this button has appeared, then we can be sure
# that the page has fully loaded.
try_for(120) { @torbrowser.child?(reload_action, roleName: 'push button') }
try_for(120) {
# The 'Reload' button (graphically shown as a looping arrow)
# is only shown when a page has loaded, so once we see the
# expected title *and* this button has appeared, then we can be sure
# that the page has fully loaded.
@torbrowser.child(reload_action, roleName: 'push button') and
@torbrowser.children(roleName: 'frame').any? { |frame|
page_titles
.map { |page_title| "#{page_title} - #{browser_name}" }
.any? { |page_title| page_title == frame.name }
}
}
end
# This step is limited to the Tor Browser due to #7502 since dogtail
# uses the same interface.
Then /^"([^"]+)" has loaded in the Tor Browser$/ do |title|
page_has_loaded_in_the_Tor_Browser(title, @language)
end
Then /^the (.*) has no plugins installed$/ do |browser|
......
......@@ -407,15 +407,15 @@ end
Given /^the Tor Browser loads the (startup page|Tails homepage|Tails roadmap)$/ do |page|
case page
when "startup page"
title = 'Tails'
titles = ['Tails', 'Tails - Trying a testing version of Tails']
when "Tails homepage"
title = 'Tails - Privacy for anyone anywhere'
titles = ['Tails - Privacy for anyone anywhere']
when "Tails roadmap"
title = 'Roadmap - Tails - Tails Ticket Tracker'
titles = ['Roadmap - Tails - Tails Ticket Tracker']
else
raise "Unsupported page: #{page}"
end
step "\"#{title}\" has loaded in the Tor Browser"
page_has_loaded_in_the_Tor_Browser(titles, @language)
end
When /^I request a new identity using Torbutton$/ do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment