aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ee/digikey/__init__.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ee/digikey/__init__.py b/src/ee/digikey/__init__.py
index b46ba85..e624db9 100644
--- a/src/ee/digikey/__init__.py
+++ b/src/ee/digikey/__init__.py
@@ -305,6 +305,7 @@ class DigikeyClient(object):
form_input, form_button = find_form()
if not form_input or not form_button:
self.driver.get(self.baseurl)
+ self._accept_cookies()
form_input, form_button = find_form()
@@ -312,7 +313,13 @@ class DigikeyClient(object):
raise EeException("Could not find form")
form_input.send_keys(query)
+
+ old_url = self.driver.current_url
form_button.click()
+ new_url = self.driver.current_url
+
+ if old_url == new_url:
+ raise EeException("Selenium error: clicked the button but the browser didn't navigate.")
page = self.driver.page_source
@@ -331,12 +338,18 @@ class DigikeyClient(object):
self.on_download("Downloading {}".format(url))
self.driver.get(url)
+ self._accept_cookies()
src = self.driver.page_source
self.cache.save(cache_key, src)
return src
+ def _accept_cookies(self):
+ cookie_blocker = self._find_first_visible("//div[@class='cookie-wrapper']//a[contains(@class, 'button')]")
+ if cookie_blocker is not None:
+ cookie_blocker.click()
+
def get_for_product_url(self, url, product_number):
return self._req(url, "product-{}".format(product_number))