Skip to content

Commit

Permalink
Fix "This browser is not longer supported" banner for some browser dr…
Browse files Browse the repository at this point in the history
…iver versions (#38)

* Fix "This browser is not longer supported" banner for some browser driver versions

* Update instadm.py

* Moved functionality in a function

* Fix
  • Loading branch information
blendicavlad authored Mar 17, 2022
1 parent 8bd2b35 commit ae181ac
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions instadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def typeMessage(self, user, message):
self.__random_sleep__()

if self.__wait_for_element__(self.selectors['send'], "xpath"):
self.__remove_browser_unsupported_banner_if_exists(self, element):
self.__get_element__(self.selectors['send'], "xpath").click()
self.__random_sleep__(3, 5)
print('Message sent successfully')
Expand Down Expand Up @@ -269,6 +270,8 @@ def __get_element__(self, element_tag, locator):
return WebDriverWait(dr, 15).until(lambda d: dr.find_element_by_xpath(element_tag))
elif locator == 'CSS' and self.is_element_present(By.CSS_SELECTOR, element_tag):
return WebDriverWait(dr, 15).until(lambda d: dr.find_element_by_css_selector(element_tag))
elif locator == 'CLASS' and self.is_element_present(By.CLASS_NAME, element_tag):
return WebDriverWait(dr, 15).until(lambda d: dr.find_element_by_class_name(element_tag))
else:
logging.info(f"Error: Incorrect locator = {locator}")
except Exception as e:
Expand Down Expand Up @@ -342,3 +345,17 @@ def __scrolldown__(self):
def teardown(self):
self.driver.close()
self.driver.quit()

def __remove_browser_unsupported_banner_if_exists(self, element):
element = self.__get_element__('rh7Wz', 'CLASS')
if element is not None:
self.driver.execute_script("""
var element = arguments[0];
element.parentNode.removeChild(element);
""", element)
element = self.__get_element__('vohlx', 'CLASS')
if element is not None:
self.driver.execute_script("""
var element = arguments[0];
element.parentNode.removeChild(element);
""", element)

0 comments on commit ae181ac

Please sign in to comment.