From 6ffddd5dbc2c77eb04a489fdb81be4f428b74522 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Wed, 5 Jan 2022 12:22:36 -0300 Subject: [PATCH] Testing some of the methods added. --- api/chrome/features/chrome.feature | 17 ++++++++++--- api/chrome/features/steps/steps.py | 38 ++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/api/chrome/features/chrome.feature b/api/chrome/features/chrome.feature index 915f7e4..a57207e 100644 --- a/api/chrome/features/chrome.feature +++ b/api/chrome/features/chrome.feature @@ -1,6 +1,17 @@ Feature: The Chrome API client - Scenario: Using the Chrome.Start method + Scenario: Using the Chrome.start method Given the Chrome client - When the Start method is called - Then Google Chrome should open \ No newline at end of file + When the start method is called + Then Google Chrome should open + + Scenario: Using the Chrome.start_headless method + Given the Chrome client + When the start_headless method is called + Then Google Chrome should open headless + + Scenario: Using the Chrome.stop method + Given the Chrome client + And a Chrome instance + When the stop method is called upon it + Then this Google Chrome instance should close \ No newline at end of file diff --git a/api/chrome/features/steps/steps.py b/api/chrome/features/steps/steps.py index 57b9622..6710a06 100644 --- a/api/chrome/features/steps/steps.py +++ b/api/chrome/features/steps/steps.py @@ -1,16 +1,44 @@ from behave import * from cli import Chrome +# ========================== Chrome.start () ========================== @given ("the Chrome client") def step_impl (context): context.client = Chrome() -@when ("the Start method is called") +@when ("the start method is called") def step_impl (context): - # context._return = None - context._return = context.client.start() + context.start_return = context.client.start() @then ("Google Chrome should open") def step_impl (context): - print (f"\n-----------\n{context._return}\n------------\n") - assert context._return == "", "Google Chrome did not opened as expected." \ No newline at end of file + assert context.start_return == "", "Google Chrome did not opened as expected." + context.client.stop() + + +# ========================== Chrome.start_headless () ========================== +@when ("the start_headless method is called") +def step_impl (context): + context.start_headless_return = context.client.start_headless() + +@then ("Google Chrome should open headless") +def step_impl (context): + assert context.start_headless_return == "", "Google Chrome did not opened as expected." + context.client.stop() + + +# ========================== Chrome.stop () ========================== +@given ("a Chrome instance") +def step_impl (context): + context.start_return = context.client.start() + +@when ("the stop method is called upon it") +def step_impl (context): + context.stop_return = context.client.stop() + +@then ("this Google Chrome instance should close") +def step_impl (context): + assert context.stop_return == "", "Google Chrome did not closed as expected." + + +# ========================== Chrome.new () ========================== \ No newline at end of file