-
-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
Sorry, I'm developing for fun and I don't know much about github, so please forgive my ignorance.
I have an idea to be added to alright (nice job, by the way @Kalebu ):
A function to send a link with link preview.
First I added another wait in init:
self.wait2 = WebDriverWait(self.browser, 5)
Then the new function:
def send_link(self, message):
try:
inp_xpath = '//*[@id="main"]/footer/div[1]/div[2]/div/div[1]/div/div[2]'
lnk_xpath = '//*[@id="main"]/footer/div[2]/div[1]/div[5]/div[1]/div[1]'
input_box = self.wait.until(
EC.presence_of_element_located((By.XPATH, inp_xpath)))
input_box.send_keys(message + Keys.SPACE)
try:
input_box2 = self.wait2.until(
EC.presence_of_element_located((By.XPATH, lnk_xpath)))
except:
pass
input_box.send_keys(" " + Keys.ENTER)
print(f"Message with link sent successfuly to {self.mobile}")
except (NoSuchElementException, Exception) as bug:
print(bug)
print(f'Failed to send a message with link to {self.mobile}')
finally:
print("send_link() finished running ")
It waits for 5 seconds for the preview to load, if it didn't load, then it sends the message anyway without preview.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels