From 95052905c5cb6f7877741de503d8e52673b20988 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Thu, 6 Jan 2022 12:38:21 -0300 Subject: [PATCH] Chrome python client tests first version finished. --- api/chrome/features/chrome.feature | 18 +++++++++++++++--- api/chrome/features/steps/steps.py | 22 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/api/chrome/features/chrome.feature b/api/chrome/features/chrome.feature index 28864dc..b292c30 100644 --- a/api/chrome/features/chrome.feature +++ b/api/chrome/features/chrome.feature @@ -57,8 +57,8 @@ Feature: The Chrome API client Then this method must return the string 'ok' # ======================== Chrome.send() ======================== -# This method cannot be tested, given it's return cannot be predicted. -# Therefore, there will be no testes for this method, at least for now. + # This method cannot be tested, given it's return cannot be predicted. + # Therefore, there will be no testes for this method, at least for now. # ======================== Chrome.open_tabs() ======================== Scenario: Using the Chrome.open_tabs method @@ -66,4 +66,16 @@ Feature: The Chrome API client And a Chrome instance And at least one Google Chrome tab is opened When the open_tabs method is called - Then it must return a list of dictionaries containing the tabs data \ No newline at end of file + Then it must return a list of dictionaries containing the tabs data + +# ======================== Chrome.find_tab_by_url() ======================== + # This method is currently broken. + # Therefore, there will be no testes for it, at least for now. + +# ======================== Chrome.find_tab_by_title() ======================== + Scenario: Using the Chrome.find_tab_by_title method + Given the Chrome client + And a Chrome instance + And at least one Google Chrome tab is opened + When the find_tab_by_title method is called + Then the id that this method returned must match the id of the tab searched \ No newline at end of file diff --git a/api/chrome/features/steps/steps.py b/api/chrome/features/steps/steps.py index 1ca578a..ff44bdf 100644 --- a/api/chrome/features/steps/steps.py +++ b/api/chrome/features/steps/steps.py @@ -123,8 +123,26 @@ def step_impl(context): assert context.open_tabs_return[1]["id"] == context.tab_id1, f""" ---------- Google id: {context.tab_id1} - Primeiro obj id: {context.open_tabs_return[1]['id']} - {context.open_tabs_return[1]['id'] == context.tab_id1} + First obj id: {context.open_tabs_return[1]['id']} + Match: {context.open_tabs_return[1]['id'] == context.tab_id1} ---------- """ + context.client.stop() + +# ======================== Chrome.find_tab_by_url() ======================== + # This method is currently broken. + # Therefore, there will be no testes for it, at least for now. + +# ======================== Chrome.find_tab_by_title() ======================== +@when("the find_tab_by_title method is called") +def step_impl(context): + context.ftbt_return = context.client.find_tab_by_title() + +@then("the id that this method returned must match the id of the tab searched") +def step_impl(context): + assert context.ftbt_return == context.tab_id1, f""" + First tab id: {context.tab_id1} + Returned id: {context.ftbt_return} + Match: {context.ftbt_return == context.tab_id1} + """ context.client.stop() \ No newline at end of file