Skip to content

Commit

Permalink
send multiple lines CamTosh#34 + bug CamTosh#43
Browse files Browse the repository at this point in the history
Allowing __type_slow__ to send a single message with newlines CamTosh#34
Fixing function call never received 'element' and 'element' overwritten in function CamTosh#43
  • Loading branch information
amastis authored Jul 26, 2022
1 parent ae181ac commit 092eafd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions instadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +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.__remove_browser_unsupported_banner_if_exists()
self.__get_element__(self.selectors['send'], "xpath").click()
self.__random_sleep__(3, 5)
print('Message sent successfully')
Expand Down Expand Up @@ -327,7 +327,11 @@ def __type_slow__(self, element_tag, locator, input_text=''):
actions = ActionChains(self.driver)
actions.click(element).perform()
for s in input_text:
element.send_keys(s)
# https://stackoverflow.com/questions/53901388/how-do-i-manipulate-shiftenter-instead-of-n/53909017#53909017
if s == '\n':
element.send_keys(Keys.SHIFT, s)
else:
element.send_keys(s)
sleep(uniform(0.25, 0.75))

except Exception as e:
Expand All @@ -346,7 +350,7 @@ def teardown(self):
self.driver.close()
self.driver.quit()

def __remove_browser_unsupported_banner_if_exists(self, element):
def __remove_browser_unsupported_banner_if_exists(self):
element = self.__get_element__('rh7Wz', 'CLASS')
if element is not None:
self.driver.execute_script("""
Expand Down

0 comments on commit 092eafd

Please sign in to comment.