From a06dcc7f0be7a0ce3f5086afe1006b3bf3056f86 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Aug 2016 16:13:38 +0200 Subject: [PATCH] BDD: Use :click-element instead of hints --- tests/end2end/data/downloads/issue1725.html | 2 +- tests/end2end/data/hints/html/simple.html | 2 +- tests/end2end/data/hints/input.html | 2 +- tests/end2end/data/hints/link_blank.html | 2 +- tests/end2end/data/javascript/issue906.html | 4 +- tests/end2end/data/marks.html | 2 +- tests/end2end/data/prompt/geolocation.html | 2 +- tests/end2end/data/prompt/jsalert.html | 2 +- tests/end2end/data/prompt/jsconfirm.html | 2 +- tests/end2end/data/prompt/jsprompt.html | 2 +- tests/end2end/data/prompt/notifications.html | 2 +- tests/end2end/features/downloads.feature | 3 +- tests/end2end/features/javascript.feature | 6 +-- tests/end2end/features/misc.feature | 6 +-- tests/end2end/features/prompts.feature | 40 ++++++++++---------- tests/end2end/features/tabs.feature | 12 ++---- tests/end2end/features/test_prompts_bdd.py | 6 --- tests/end2end/features/yankpaste.feature | 16 ++------ tests/end2end/test_insert_mode.py | 21 +++++----- 19 files changed, 57 insertions(+), 77 deletions(-) diff --git a/tests/end2end/data/downloads/issue1725.html b/tests/end2end/data/downloads/issue1725.html index b413e69f2..45f24de4e 100644 --- a/tests/end2end/data/downloads/issue1725.html +++ b/tests/end2end/data/downloads/issue1725.html @@ -5,7 +5,7 @@

Using :prompt-open-download with a file that has a loooooong filename

- + Download me!

diff --git a/tests/end2end/data/hints/html/simple.html b/tests/end2end/data/hints/html/simple.html index 40e908a13..52cd69cbb 100644 --- a/tests/end2end/data/hints/html/simple.html +++ b/tests/end2end/data/hints/html/simple.html @@ -8,6 +8,6 @@ Simple link - Follow me! + Follow me! diff --git a/tests/end2end/data/hints/input.html b/tests/end2end/data/hints/input.html index 87cc3b347..9c93da15e 100644 --- a/tests/end2end/data/hints/input.html +++ b/tests/end2end/data/hints/input.html @@ -6,6 +6,6 @@ Simple input -
+
diff --git a/tests/end2end/data/hints/link_blank.html b/tests/end2end/data/hints/link_blank.html index f738e61dc..fc11c0167 100644 --- a/tests/end2end/data/hints/link_blank.html +++ b/tests/end2end/data/hints/link_blank.html @@ -5,6 +5,6 @@ A link to use hints on - Follow me! + Follow me! diff --git a/tests/end2end/data/javascript/issue906.html b/tests/end2end/data/javascript/issue906.html index 14378971f..dbbf54ee9 100644 --- a/tests/end2end/data/javascript/issue906.html +++ b/tests/end2end/data/javascript/issue906.html @@ -2,8 +2,8 @@ - - + + - + diff --git a/tests/end2end/data/prompt/jsalert.html b/tests/end2end/data/prompt/jsalert.html index d4af29850..0d5076b4f 100644 --- a/tests/end2end/data/prompt/jsalert.html +++ b/tests/end2end/data/prompt/jsalert.html @@ -10,6 +10,6 @@ - + diff --git a/tests/end2end/data/prompt/jsconfirm.html b/tests/end2end/data/prompt/jsconfirm.html index 292b5e2c8..d89137ebd 100644 --- a/tests/end2end/data/prompt/jsconfirm.html +++ b/tests/end2end/data/prompt/jsconfirm.html @@ -10,6 +10,6 @@ - + diff --git a/tests/end2end/data/prompt/jsprompt.html b/tests/end2end/data/prompt/jsprompt.html index bc4178a6f..d8c848553 100644 --- a/tests/end2end/data/prompt/jsprompt.html +++ b/tests/end2end/data/prompt/jsprompt.html @@ -10,6 +10,6 @@ - + diff --git a/tests/end2end/data/prompt/notifications.html b/tests/end2end/data/prompt/notifications.html index a4e08e50d..f96456ff2 100644 --- a/tests/end2end/data/prompt/notifications.html +++ b/tests/end2end/data/prompt/notifications.html @@ -34,6 +34,6 @@ - + diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature index 5b623442d..6c094d421 100644 --- a/tests/end2end/features/downloads.feature +++ b/tests/end2end/features/downloads.feature @@ -201,8 +201,7 @@ Feature: Downloading things from a website. Scenario: Directly open a download with a very long filename When I set storage -> prompt-download-directory to true And I open data/downloads/issue1725.html - And I run :hint - And I run :follow-hint a + And I run :click-element id long-link And I wait for "Asking question text='Save file to:'>, *" in the log And I directly open the download And I wait until the download is finished diff --git a/tests/end2end/features/javascript.feature b/tests/end2end/features/javascript.feature index 979dd5cbf..bb34db70b 100644 --- a/tests/end2end/features/javascript.feature +++ b/tests/end2end/features/javascript.feature @@ -12,10 +12,8 @@ Feature: Javascript stuff Scenario: Closing a JS window twice (issue 906) When I open about:blank And I open data/javascript/issue906.html in a new tab - And I run :hint - And I run :follow-hint a + And I run :click-element id open-button And I wait for "Changing title for idx 2 to 'about:blank'" in the log And I run :tab-focus 2 - And I run :hint - And I run :follow-hint s + And I run :click-element id close-button Then "Requested to close * which does not exist!" should be logged diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index ab7599e03..b6c606551 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -372,8 +372,7 @@ Feature: Various utility commands. @pyqt>=5.3.1 Scenario: Focusing download widget via Tab (original issue) When I open data/prompt/jsprompt.html - And I run :hint - And I run :follow-hint a + And I run :click-element id button And I wait for "Entering mode KeyMode.prompt *" in the log And I press the key "" And I press the key "" @@ -519,8 +518,7 @@ Feature: Various utility commands. When I run :hint And I run :leave-mode And I run :repeat-command - And I run :follow-hint a - And I wait until data/hello.txt is loaded + And I run :click-element id link Then the following tabs should be open: - data/hints/link_blank.html - data/hello.txt (active) diff --git a/tests/end2end/features/prompts.feature b/tests/end2end/features/prompts.feature index f781cf1d3..633f465b6 100644 --- a/tests/end2end/features/prompts.feature +++ b/tests/end2end/features/prompts.feature @@ -8,7 +8,7 @@ Feature: Prompts Scenario: Javascript alert When I open data/prompt/jsalert.html - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-accept Then the javascript message "Alert done" should be logged @@ -16,26 +16,26 @@ Feature: Prompts Scenario: Using content -> ignore-javascript-alert When I set content -> ignore-javascript-alert to true And I open data/prompt/jsalert.html - And I click the button + And I run :click-element id button Then the javascript message "Alert done" should be logged Scenario: Javascript confirm - yes When I open data/prompt/jsconfirm.html - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-yes Then the javascript message "confirm reply: true" should be logged Scenario: Javascript confirm - no When I open data/prompt/jsconfirm.html - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-no Then the javascript message "confirm reply: false" should be logged Scenario: Javascript confirm - aborted When I open data/prompt/jsconfirm.html - And I click the button + And I run :click-element id button And I wait for a prompt And I run :leave-mode Then the javascript message "confirm reply: false" should be logged @@ -43,7 +43,7 @@ Feature: Prompts @pyqt>=5.3.1 Scenario: Javascript prompt When I open data/prompt/jsprompt.html - And I click the button + And I run :click-element id button And I wait for a prompt And I press the keys "prompt test" And I run :prompt-accept @@ -52,7 +52,7 @@ Feature: Prompts @pyqt>=5.3.1 Scenario: Rejected javascript prompt When I open data/prompt/jsprompt.html - And I click the button + And I run :click-element id button And I wait for a prompt And I press the keys "prompt test" And I run :leave-mode @@ -66,7 +66,7 @@ Feature: Prompts When selection is supported And I put "insert test" into the primary selection And I open data/prompt/jsprompt.html - And I click the button + And I run :click-element id button And I wait for a prompt And I press the keys "" And I run :prompt-accept @@ -76,7 +76,7 @@ Feature: Prompts Scenario: Using content -> ignore-javascript-prompt When I set content -> ignore-javascript-prompt to true And I open data/prompt/jsprompt.html - And I click the button + And I run :click-element id button Then the javascript message "Prompt reply: null" should be logged # SSL @@ -119,21 +119,21 @@ Feature: Prompts Scenario: Always rejecting geolocation When I set content -> geolocation to false And I open data/prompt/geolocation.html in a new tab - And I click the button + And I run :click-element id button Then the javascript message "geolocation permission denied" should be logged @ci @not_osx Scenario: Always accepting geolocation When I set content -> geolocation to true And I open data/prompt/geolocation.html in a new tab - And I click the button + And I run :click-element id button Then the javascript message "geolocation permission denied" should not be logged @ci @not_osx Scenario: geolocation with ask -> true When I set content -> geolocation to ask And I open data/prompt/geolocation.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-yes Then the javascript message "geolocation permission denied" should not be logged @@ -141,7 +141,7 @@ Feature: Prompts Scenario: geolocation with ask -> false When I set content -> geolocation to ask And I open data/prompt/geolocation.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-no Then the javascript message "geolocation permission denied" should be logged @@ -149,7 +149,7 @@ Feature: Prompts Scenario: geolocation with ask -> abort When I set content -> geolocation to ask And I open data/prompt/geolocation.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :leave-mode Then the javascript message "geolocation permission denied" should be logged @@ -159,19 +159,19 @@ Feature: Prompts Scenario: Always rejecting notifications When I set content -> notifications to false And I open data/prompt/notifications.html in a new tab - And I click the button + And I run :click-element id button Then the javascript message "notification permission denied" should be logged Scenario: Always accepting notifications When I set content -> notifications to true And I open data/prompt/notifications.html in a new tab - And I click the button + And I run :click-element id button Then the javascript message "notification permission granted" should be logged Scenario: notifications with ask -> false When I set content -> notifications to ask And I open data/prompt/notifications.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-no Then the javascript message "notification permission denied" should be logged @@ -179,7 +179,7 @@ Feature: Prompts Scenario: notifications with ask -> true When I set content -> notifications to ask And I open data/prompt/notifications.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :prompt-yes Then the javascript message "notification permission granted" should be logged @@ -189,7 +189,7 @@ Feature: Prompts Scenario: notifications with ask -> abort When I set content -> notifications to ask And I open data/prompt/notifications.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :leave-mode Then the javascript message "notification permission aborted" should be logged @@ -197,7 +197,7 @@ Feature: Prompts Scenario: answering notification after closing tab When I set content -> notifications to ask And I open data/prompt/notifications.html in a new tab - And I click the button + And I run :click-element id button And I wait for a prompt And I run :tab-close And I wait for "Leaving mode KeyMode.yesno (reason: aborted)" in the log diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index b3233fcb4..665931ce1 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -806,8 +806,7 @@ Feature: Tab management And I set tabs -> background-tabs to false And I open about:blank And I open data/hints/html/simple.html in a new tab - And I run :hint all tab - And I run :follow-hint a + And I run :click-element id link --target=tab And I wait until data/hello.txt is loaded Then the following tabs should be open: - about:blank @@ -819,8 +818,7 @@ Feature: Tab management And I set tabs -> background-tabs to false And I open about:blank And I open data/hints/html/simple.html in a new tab - And I run :hint all tab - And I run :follow-hint a + And I run :click-element id link --target=tab And I wait until data/hello.txt is loaded Then the following tabs should be open: - about:blank @@ -832,8 +830,7 @@ Feature: Tab management And I set tabs -> background-tabs to false And I open about:blank And I open data/hints/html/simple.html in a new tab - And I run :hint all tab - And I run :follow-hint a + And I run :click-element id link --target=tab And I wait until data/hello.txt is loaded Then the following tabs should be open: - data/hello.txt (active) @@ -846,8 +843,7 @@ Feature: Tab management And I open data/hints/html/simple.html And I open about:blank in a new tab And I run :tab-focus last - And I run :hint all tab - And I run :follow-hint a + And I run :click-element id link --target=tab And I wait until data/hello.txt is loaded Then the following tabs should be open: - data/hints/html/simple.html diff --git a/tests/end2end/features/test_prompts_bdd.py b/tests/end2end/features/test_prompts_bdd.py index d4b2dbc8c..521a08f42 100644 --- a/tests/end2end/features/test_prompts_bdd.py +++ b/tests/end2end/features/test_prompts_bdd.py @@ -33,12 +33,6 @@ def wait_ssl_page_finished_loading(quteproc, ssl_server): load_status='warn') -@bdd.when("I click the button") -def click_button(quteproc): - quteproc.send_cmd(':hint') - quteproc.send_cmd(':follow-hint a') - - @bdd.when("I wait for a prompt") def wait_for_prompt(quteproc): quteproc.wait_for(message='Entering mode KeyMode.* (reason: question ' diff --git a/tests/end2end/features/yankpaste.feature b/tests/end2end/features/yankpaste.feature index 2bd865420..6d732d7c9 100644 --- a/tests/end2end/features/yankpaste.feature +++ b/tests/end2end/features/yankpaste.feature @@ -219,9 +219,7 @@ Feature: Yanking and pasting. Scenario: Inserting text into an empty text field When I open data/paste_primary.html - # Click the text field - And I run :hint all - And I run :follow-hint a + And I run :click-element id qute-textarea And I wait for "Clicked editable element!" in the log And I run :insert-text Hello world # Compare @@ -230,9 +228,7 @@ Feature: Yanking and pasting. Scenario: Inserting text into a text field at specific position When I open data/paste_primary.html And I set the text field to "one two three four" - # Click the text field - And I run :hint all - And I run :follow-hint a + And I run :click-element id qute-textarea And I wait for "Clicked editable element!" in the log # Move to the beginning and two characters to the right And I press the keys "" @@ -244,9 +240,7 @@ Feature: Yanking and pasting. Scenario: Inserting text into a text field with undo When I open data/paste_primary.html - # Click the text field - And I run :hint all - And I run :follow-hint a + And I run :click-element id qute-textarea And I wait for "Clicked editable element!" in the log # Paste and undo And I run :insert-text This text should be undone @@ -264,9 +258,7 @@ Feature: Yanking and pasting. Scenario: Inserting text with a read-only field When I open data/paste_primary.html - # Click the text field - And I run :hint all - And I run :follow-hint s + And I run :click-element id qute-textarea-noedit And I wait for "Clicked non-editable element!" in the log And I run :enter-mode insert And I run :insert-text test diff --git a/tests/end2end/test_insert_mode.py b/tests/end2end/test_insert_mode.py index 941c2cc74..552fffbb4 100644 --- a/tests/end2end/test_insert_mode.py +++ b/tests/end2end/test_insert_mode.py @@ -25,20 +25,23 @@ import json import pytest -@pytest.mark.parametrize('file_name, source, input_text, auto_insert', [ - ('textarea.html', 'clipboard', 'qutebrowser', 'false'), - ('textarea.html', 'keypress', 'superqutebrowser', 'false'), - ('input.html', 'clipboard', 'amazingqutebrowser', 'false'), - ('input.html', 'keypress', 'awesomequtebrowser', 'false'), - ('autofocus.html', 'keypress', 'cutebrowser', 'true'), +@pytest.mark.parametrize(['file_name', 'elem_id', 'source', 'input_text', + 'auto_insert'], [ + ('textarea.html', 'qute-textarea', 'clipboard', 'qutebrowser', 'false'), + ('textarea.html', 'qute-textarea', 'keypress', 'superqutebrowser', + 'false'), + ('input.html', 'qute-input', 'clipboard', 'amazingqutebrowser', 'false'), + ('input.html', 'qute-input', 'keypress', 'awesomequtebrowser', 'false'), + ('autofocus.html', 'qute-input-autofocus', 'keypress', 'cutebrowser', + 'true'), ]) -def test_insert_mode(file_name, source, input_text, auto_insert, quteproc): +def test_insert_mode(file_name, elem_id, source, input_text, auto_insert, + quteproc): url_path = 'data/insert_mode_settings/html/{}'.format(file_name) quteproc.open_path(url_path) quteproc.set_setting('input', 'auto-insert-mode', auto_insert) - quteproc.send_cmd(':hint all') - quteproc.send_cmd(':follow-hint a') + quteproc.send_cmd(':click-element id {}'.format(elem_id)) quteproc.wait_for(message='Clicked editable element!') quteproc.send_cmd(':debug-set-fake-clipboard')