Skip to content

Commit

Permalink
#62 Handle cookie banner earlier to prevent problems while login
Browse files Browse the repository at this point in the history
  • Loading branch information
StegSchreck committed Oct 12, 2018
1 parent b002a58 commit 4172f79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tests/assets/exports/*
*geckodriver.log
build
dist
venv
6 changes: 6 additions & 0 deletions RatS/base/base_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def login(self):
self.browser.get(self.LOGIN_PAGE)
time.sleep(1)

self._handle_cookie_notice_if_present()

iteration = 0
while self._user_is_not_logged_in():
iteration += 1
Expand All @@ -80,6 +82,10 @@ def login(self):
if iteration > 2:
self._handle_login_unsuccessful()

def _handle_cookie_notice_if_present(self):
# to be implemented for sites with cookie banners individually
pass

def _handle_captcha_challenge_if_present(self):
# to be implemented for sites with captchas individually
pass
Expand Down
9 changes: 0 additions & 9 deletions RatS/tmdb/tmdb_ratings_inserter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import time

from RatS.base.base_ratings_uploader import RatingsUploader
from RatS.tmdb.tmdb_site import TMDB

Expand All @@ -14,10 +12,3 @@ def __init__(self, args):
@staticmethod
def _get_url_for_csv_upload():
return 'https://www.themoviedb.org/settings/import-list'

def pre_upload_action(self):
cookie_accept_button = self.site.browser.find_element_by_id('cookie_notice')\
.find_elements_by_class_name('accept')
if cookie_accept_button is not None and len(cookie_accept_button) > 0:
cookie_accept_button[0].click()
time.sleep(1)
9 changes: 9 additions & 0 deletions RatS/tmdb/tmdb_site.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

from RatS.base.base_site import Site


Expand All @@ -14,3 +16,10 @@ def __init__(self, args):

def _get_login_page_url(self):
return "https://www.themoviedb.org/login"

def _handle_cookie_notice_if_present(self):
cookie_accept_button = self.browser.find_element_by_id('cookie_notice')\
.find_elements_by_class_name('accept')
if cookie_accept_button is not None and len(cookie_accept_button) > 0:
cookie_accept_button[0].click()
time.sleep(1)

0 comments on commit 4172f79

Please sign in to comment.