Skip to content

Commit e53565b

Browse files
committed
userDataDir and --no-sandbox options added to chromium launch (seem to work better for signing in)
1 parent b976c20 commit e53565b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
venv
33
build
44
dist
5+
.user-data
56
*.pyc
67
*.spec
78
*.pkl

KrogerAPI.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
class KrogerAPI:
1212
browser_options = {
1313
'headless': True,
14-
'args': ['--blink-settings=imagesEnabled=false'] # Disable images for hopefully faster load-time
14+
'userDataDir': '.user-data',
15+
'args': ['--blink-settings=imagesEnabled=false', # Disable images for hopefully faster load-time
16+
'--no-sandbox']
1517
}
1618
headers = {
1719
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
@@ -220,6 +222,7 @@ async def init(self):
220222
await self.page.setViewport({'width': 700, 'height': 0})
221223

222224
async def destroy(self):
225+
await self.page.close()
223226
await self.browser.close()
224227

225228
async def sign_in_routine(self, redirect_url='/account/update', contains=None):
@@ -248,7 +251,9 @@ async def sign_in(self, redirect_url, contains):
248251
if not self.browser_options['headless']:
249252
timeout = 60000
250253
await self.page.goto('https://www.' + self.cli.config['main']['domain'] + '/signin?redirectUrl=' + redirect_url)
254+
await self.page.click('#SignIn-emailInput', {'clickCount': 3}) # Select all in the field
251255
await self.page.type('#SignIn-emailInput', self.cli.username)
256+
await self.page.click('#SignIn-passwordInput', {'clickCount': 3})
252257
await self.page.type('#SignIn-passwordInput', self.cli.password)
253258
await self.page.keyboard.press('Enter')
254259
try:

0 commit comments

Comments
 (0)