From: Antoine Musso Date: Wed, 8 Jul 2015 16:32:53 +0000 (+0200) Subject: Browser test: avoid loading elements over network X-Git-Tag: 1.31.0-rc.0~9992 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=d737e5762438b72bd2b1ec10937555b32b664788 Browser test: avoid loading elements over network Page object let us search elements for which attributes match a given regex. Unfortunatly it loads the list of elements first, then foreach of them trigger a call to Selenium to retrieve the attribute to match. Attempting to regex match a link href, would cause hundred of roundtrip to the Selenium host. Instead, use a CSS selector to get the element we are interested in which skips the bad page object code. Bug: T92613 Bug: T112291 Change-Id: I12949a4d0ef61d38adbaaf622722c89033949cad --- diff --git a/tests/browser/features/support/pages/main_page.rb b/tests/browser/features/support/pages/main_page.rb index 6d76b01c4e..3092ab5cd2 100644 --- a/tests/browser/features/support/pages/main_page.rb +++ b/tests/browser/features/support/pages/main_page.rb @@ -3,16 +3,16 @@ class MainPage page_url '' - a(:edit_link, href: /action=edit/) + a(:edit_link, css: '#ca-edit a') li(:help_link, id: 'n-help') div(:page_content, id: 'content') li(:page_information_link, id: 't-info') li(:permanent_link_link, id: 't-permalink') - a(:printable_version_link, href: /printable=yes/) + a(:printable_version_link, css: '#t-print a') li(:random_page_link, id: 'n-randompage') li(:recent_changes_link, id: 'n-recentchanges') li(:related_changes_link, id: 't-recentchangeslinked') li(:special_pages_link, id: 't-specialpages') - a(:view_history_link, href: /action=history/) + a(:view_history_link, css: '#ca-history a') li(:what_links_here_link, id: 't-whatlinkshere') end diff --git a/tests/browser/features/support/pages/preferences_appearance_page.rb b/tests/browser/features/support/pages/preferences_appearance_page.rb index 83c3952f6b..1e5ffaa18f 100644 --- a/tests/browser/features/support/pages/preferences_appearance_page.rb +++ b/tests/browser/features/support/pages/preferences_appearance_page.rb @@ -27,7 +27,7 @@ class PreferencesAppearancePage radio_button(:monobook, id: 'mw-input-wpskin-monobook') radio_button(:no_preference_radio, id: 'mw-input-wpdate-default') text_field(:other_offset, id: 'mw-input-wptimecorrection-other') - a(:restore_default_link, href: /reset/) + a(:restore_default_link, id: 'mw-prefs-restoreprefs') select_list(:size_select, id: 'mw-input-wpimagesize') select_list(:threshold_select, id: 'mw-input-wpstubthreshold') select_list(:time_offset_select, id: 'mw-input-wptimecorrection') diff --git a/tests/browser/features/support/pages/view_history_page.rb b/tests/browser/features/support/pages/view_history_page.rb index bb9c58628a..ee4d757a05 100644 --- a/tests/browser/features/support/pages/view_history_page.rb +++ b/tests/browser/features/support/pages/view_history_page.rb @@ -1,6 +1,6 @@ class ViewHistoryPage include PageObject - a(:view_history_link, href: /action=history/) - a(:old_version_link, href: /oldid=/) + a(:view_history_link, css: '#ca-history a') + a(:old_version_link, css: '#pagehistory a.mw-changeslist-date') end