Skip to content

Commit 6921679

Browse files
authored
disable sandbox if not window platform (#21)
1 parent 74ae2fb commit 6921679

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

PuppeteerLibrary/keywords/browsermanagement.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time
2+
import sys
23
from robot.utils import timestr_to_secs
34
from pyppeteer import launch
45
from PuppeteerLibrary.base.librarycomponent import LibraryComponent
@@ -32,6 +33,7 @@ def open_browser(self, url, browser="chrome", alias=None, options=None):
3233
3334
"""
3435
async def open_browser_async():
36+
default_args = []
3537
default_options = {
3638
'headless': True,
3739
'width': 1366,
@@ -42,6 +44,10 @@ async def open_browser_async():
4244
merged_options = default_options
4345
else:
4446
merged_options = {**default_options, **options}
47+
48+
if 'win' not in sys.platform.lower():
49+
default_args = ['--no-sandbox', '--disable-setuid-sandbox']
50+
4551
self.info(('Open browser to ' + url + '\n' +
4652
str(merged_options)))
4753
self.ctx.browser = await launch(
@@ -50,9 +56,7 @@ async def open_browser_async():
5056
'width': merged_options['width'],
5157
'height': merged_options['height']
5258
},
53-
# Only for ubuntu
54-
# args=['--no-sandbox', '--disable-setuid-sandbox'])
55-
args=['--disable-setuid-sandbox'])
59+
args=default_args)
5660
self.ctx.current_page = await self.ctx.browser.newPage()
5761
await self.ctx.current_page.goto(url)
5862
await self.ctx.current_page.screenshot({'path': 'example.png'})

0 commit comments

Comments
 (0)