Skip to content

Commit 8ba7e5d

Browse files
committed
ENH: Implement xfail in case firefox and CI
1 parent c2b20b1 commit 8ba7e5d

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,8 @@ def web(request, tmp_folder: str, download_driver: str):
113113
web.stop_browser()
114114

115115

116-
def get_event_result(id_event: str, web: WebBot, test: str = "") -> typing.Dict:
116+
def get_event_result(id_event: str, web: WebBot) -> typing.Dict:
117117
event_result = web.find_element(id_event, By.ID)
118-
if test in ["test_left_double_click_relative", "test_right_click_relative", "test_left_click_relative"
119-
"test_triple_click_relative"]:
120-
print(event_result)
121-
print(event_result.text)
122118
return json.loads(event_result.text)
123119

124120

tests/test_mouse.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from botcity.web import WebBot, By
55
from pytest import xfail
66

7-
BROWSER_ERRORS = ['firefox']
8-
97

108
def test_left_click(web: WebBot):
119
web.browse(conftest.INDEX_PAGE)
@@ -44,17 +42,17 @@ def test_left_triple_click(web: WebBot):
4442

4543

4644
def test_triple_click_relative(web: WebBot):
47-
# if web.browser.lower() in BROWSER_ERRORS:
48-
# xfail(reason=f"Error in {web.browser} in decode dict.")
45+
if web.browser.lower() in 'firefox' and os.getenv('CI') is not None:
46+
xfail(reason=f"Firefox is not working in CI")
4947

5048
web.browse(conftest.INDEX_PAGE)
5149

5250
web.add_image('mouse', os.path.join(conftest.PROJECT_DIR, 'resources', 'mouse.png'))
5351
if not web.find("mouse", matching=0.97, waiting_time=10_000):
5452
raise Exception('Image not found: mouse')
5553
web.triple_click_relative(16, 140)
56-
web.wait(5000)
57-
result = conftest.get_event_result('element-result', web, test="test_triple_click_relative")
54+
55+
result = conftest.get_event_result('element-result', web)
5856
assert result['data'] == ['Left2', 'Left2', 'Left2']
5957

6058

@@ -83,44 +81,45 @@ def test_right_double_click(web: WebBot):
8381

8482

8583
def test_left_click_relative(web: WebBot):
86-
# if web.browser.lower() in BROWSER_ERRORS:
87-
# xfail(reason=f"Error in {web.browser} in decode dict.")
84+
if web.browser.lower() in 'firefox' and os.getenv('CI') is not None:
85+
xfail(reason=f"Firefox is not working in CI")
8886
web.browse(conftest.INDEX_PAGE)
8987

9088
web.add_image('mouse', os.path.join(conftest.PROJECT_DIR, 'resources', 'mouse.png'))
9189
if not web.find("mouse", matching=0.97, waiting_time=10_000):
9290
raise Exception('Image not found: mouse')
9391
web.click_relative(16, 140)
94-
web.wait(5000)
95-
result = conftest.get_event_result('element-result', web, test="test_left_click_relative")
92+
93+
result = conftest.get_event_result('element-result', web)
9694
assert result['data'] == ['Left2']
9795

9896

9997
def test_left_double_click_relative(web: WebBot):
100-
# if web.browser.lower() in BROWSER_ERRORS:
101-
# xfail(reason=f"Error in {web.browser} in decode dict.")
98+
if web.browser.lower() in 'firefox' and os.getenv('CI') is not None:
99+
xfail(reason=f"Firefox is not working in CI")
100+
102101
web.browse(conftest.INDEX_PAGE)
103102

104103
web.add_image('mouse', os.path.join(conftest.PROJECT_DIR, 'resources', 'mouse.png'))
105104
if not web.find("mouse", matching=0.97, waiting_time=10_000):
106105
raise Exception('Image not found: mouse')
107106
web.double_click_relative(16, 140)
108-
web.wait(5000)
109-
result = conftest.get_event_result('element-result', web, test="test_left_double_click_relative")
107+
108+
result = conftest.get_event_result('element-result', web)
110109
assert result['data'] == ['Left2', 'Left2']
111110

112111

113112
def test_right_click_relative(web: WebBot):
114-
# if web.browser.lower() in BROWSER_ERRORS:
115-
# xfail(reason=f"Error in {web.browser} visual automation headless")
113+
if web.browser.lower() in 'firefox' and os.getenv('CI') is not None:
114+
xfail(reason=f"Firefox is not working in CI")
116115
web.browse(conftest.INDEX_PAGE)
117116

118117
web.add_image('mouse', os.path.join(conftest.PROJECT_DIR, 'resources', 'mouse.png'))
119118
if not web.find("mouse", matching=0.97, waiting_time=10_000):
120119
raise Exception('Image not found: mouse')
121120
web.right_click_relative(16, 140)
122-
web.wait(5000)
123-
result = conftest.get_event_result('element-result', web, test="test_right_click_relative")
121+
122+
result = conftest.get_event_result('element-result', web)
124123
assert result['data'] == ['Right2']
125124

126125

@@ -170,7 +169,7 @@ def test_move_relative(web: WebBot):
170169
web.add_image('mouse', os.path.join(conftest.PROJECT_DIR, 'resources', 'mouse.png'))
171170
if not web.find("mouse", matching=0.97, waiting_time=10_000):
172171
raise Exception('Image not found: mouse')
173-
web.move() # posicionando o mouse
172+
web.move()
174173
web.move_relative(16, 140)
175174

176175
result = conftest.get_event_result('element-result', web)
@@ -247,4 +246,3 @@ def test_get_element_coors_centered(web: WebBot):
247246

248247
result = conftest.get_event_result('element-result', web)
249248
assert result['data'] == ['Left'] or result['data'] == ['Left2']
250-

0 commit comments

Comments
 (0)