Skip to content

Commit 54a8aaf

Browse files
committed
FIX: Remove xfails and implement download cdp in chrome
1 parent b855a18 commit 54a8aaf

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

botcity/web/bot.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _get_service(self):
281281
return service
282282

283283
def _others_configurations(self):
284-
if self.browser == Browser.UNDETECTED_CHROME:
284+
if self.browser in [Browser.UNDETECTED_CHROME, Browser.CHROME, Browser.EDGE]:
285285
"""
286286
There is a problem in undetected chrome that prevents downloading files even passing
287287
download_folder_path in preferences.
@@ -1130,20 +1130,12 @@ def print_pdf(self, path=None, print_options=None):
11301130
return default_path
11311131

11321132
if print_options is None:
1133-
print_options = {
1134-
'landscape': False,
1135-
'displayHeaderFooter': False,
1136-
'printBackground': True,
1137-
'preferCSSPageSize': True,
1138-
'marginTop': 0,
1139-
'marginBottom': 0
1140-
}
1141-
print_options = PrintOptions()
1142-
print_options.page_ranges = ['1-2']
1143-
print_options.margin_top = 0
1144-
print_options.margin_bottom = 0
1145-
print_options.background = True
1146-
print_options.orientation = 'landscape'
1133+
print_options = PrintOptions()
1134+
print_options.page_ranges = ['1-2']
1135+
print_options.margin_top = 0
1136+
print_options.margin_bottom = 0
1137+
print_options.background = True
1138+
print_options.orientation = 'landscape'
11471139
data = self._driver.print_page(print_options)
11481140
bytes_file = base64.b64decode(data)
11491141
if not path:

tests/test_browser.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def test_scroll_up(web: WebBot):
236236
assert mouse_icon is not None
237237

238238

239-
@pytest.mark.xfail
240239
def test_set_screen_resolution(web: WebBot):
241240
web.browse(conftest.INDEX_PAGE)
242241
web.set_screen_resolution(500, 500)
@@ -246,20 +245,18 @@ def test_set_screen_resolution(web: WebBot):
246245
assert width == '500'
247246

248247

249-
@pytest.mark.xfail(reason="Unknown chrome/undetected error to be investigated.")
250248
def test_wait_for_downloads(web: WebBot):
251249
fake_bin_path = conftest.get_fake_bin_path(web=web)
252250

253251
web.browse(conftest.INDEX_PAGE)
254-
255252
web.type_keys([web.KEYS.SHIFT, 'q'])
256253

257254
web.wait_for_downloads(timeout=60000)
258255
web.wait(5000)
259256

260257
assert os.path.exists(fake_bin_path) and os.path.getsize(fake_bin_path) > 0
261258

262-
@pytest.mark.xfail(reason="Unknown chrome/undetected error to be investigated.")
259+
263260
def test_wait_for_file(web: WebBot):
264261
fake_bin_path = conftest.get_fake_bin_path(web=web)
265262

@@ -290,7 +287,6 @@ def test_set_current_element(web: WebBot):
290287
assert result['data'] == ['Left2'] or result['data'] == ['Left']
291288

292289

293-
# @pytest.mark.xfail(reason="Unknown chrome/undetected error to be investigated.")
294290
def test_print_pdf(web: WebBot, tmp_folder):
295291
web.browse(conftest.INDEX_PAGE)
296292
pdf = web.print_pdf(path=os.path.join(tmp_folder, 'page.pdf'))

tests/test_vision.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_get_last_element(web: WebBot):
4444
assert ele is not None
4545

4646

47-
@pytest.mark.xfail(reason="find return None in windows chrome")
4847
def test_find_text(web: WebBot):
4948
web.browse(conftest.INDEX_PAGE)
5049
web.set_screen_resolution(3000, 2000)

0 commit comments

Comments
 (0)