Skip to content

Commit bd38141

Browse files
adding static code analyzer flake8
1 parent 12a962b commit bd38141

File tree

8 files changed

+16
-10
lines changed

8 files changed

+16
-10
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
max_complexity = 10
3+
max-line-length = 120
4+
statistics = True
5+
count = True
6+
ignore = W191,E117

Library/driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def __init__(self) -> None:
2323
options.add_argument("--headless")
2424
self.driver = webdriver.Chrome(options=options)
2525
self.driver.implicitly_wait(int(Var.glob("implicit_wait")))
26-
self.driver.set_window_size(int(Var.glob("browser_horizontal_size")), int(Var.glob("browser_vertical_size")))
26+
self.driver.set_window_size(int(Var.glob("browser_horizontal_size")),
27+
int(Var.glob("browser_vertical_size")))
2728
elif browser == "firefox":
2829
self.driver = webdriver.Firefox()
2930
elif browser == "safari":
@@ -60,4 +61,3 @@ def current_url(self) -> str:
6061

6162
def quit(self):
6263
self.driver.quit()
63-

Library/locator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def click_if_displayed(self) -> bool:
9696
try:
9797
self.is_displayed_with_wait()
9898
var = Store.current_driver.find_element(self.by, self.value).click
99+
print("Click action complete on:" + self.by + "with " + self.value + "return value: " + var)
99100
except Exception as e:
100101
print("click if displayed not worked at \n" + self.by + "\n" + self.value + "\n Exception: \n" + str(e))
101102
return False
@@ -119,7 +120,7 @@ def scroll_to_locator_using_js(self) -> bool:
119120
scroll_locator = Store.current_driver.find_element(self.by, self.value)
120121
Store.current_driver.execute_script('arguments[0].scrollIntoView(true);', scroll_locator)
121122
except Exception as e:
122-
print("scroll to locator using js not worked at \n" + self.by + "\n" + self.value + "\n Exception: \n" + str(e))
123+
print("scroll to locator using js not worked at:" + self.by + ":" + self.value + " Exception: " + str(e))
123124
return False
124125
else:
125126
return True
@@ -139,11 +140,12 @@ def get_element(self) -> webelement.WebElement:
139140
try:
140141
return Store.current_driver.find_element(self.by, self.value)
141142
except Exception as e:
142-
print("scroll to locator using js not worked at \n" + self.by + "\n" + self.value + "\n Exception: \n" + str(e))
143+
print("get element not worked at \n" + self.by + "\n" + self.value + "\n Exception: \n" + str(e))
143144

144145
def clear_and_send_keys(self, string) -> bool:
145146
try:
146147
var = Store.current_driver.find_element(self.by, self.value).clear
148+
print("Clear action completed on: " + self.by + " and " + self.value + " Return value is: " + var)
147149
Store.current_driver.find_element(self.by, self.value).send_keys(string)
148150
except Exception as e:
149151
print("Clear and Send keys not worked at \n" + self.by + "\n" + self.value + "\n Exception: \n" + str(e))

Library/store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from selenium import webdriver
2-
from selenium.webdriver.chrome.webdriver import WebDriver
32

43

54
class Store:

Library/variable.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def write(self, params):
6666
if self.env("snap") == "1":
6767
with open(self.file_path, 'w') as file:
6868
documents = yaml.dump(params, file)
69+
print(documents)
6970

7071
def dynamic_value_for(self, string) -> str:
7172
try:

Locators/google.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from selenium.webdriver.common.by import By
21
from Library.locator import Locator
32

43

Tests/google.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import pytest
21
import allure
3-
import os
42
from Library.driver import Driver
53
from Pages.google import GooglePage
64
from Library.variable import Var
@@ -20,7 +18,7 @@ def test_google_search():
2018
print("landed in google home page")
2119

2220
with allure.step("second step"):
23-
assert (GooglePage.is_search_box_displayed() == True)
21+
assert (GooglePage.is_search_box_displayed() is True)
2422
GooglePage.enter_search_text(variable.local_value_for("search_text"))
2523
dynamic_data["search_text"] = GooglePage.get_search_text()
2624
dynamic_data["name"] = GooglePage.search_box.get_attribute("name")

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ pytest-xdist==1.31.0
88
lxml==4.4.2
99
allure-pytest==2.8.6
1010
ipdb == 0.12.3
11-
pyyaml == 5.3
11+
pyyaml == 5.3
12+
flake8 == 3.7.9

0 commit comments

Comments
 (0)