alright
alright copied to clipboard
Link preview
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.
Create a pull request to add your function. See https://opensource.com/article/19/7/create-pull-request-github to learn how
Hello @amelsakka, You're warmly welcomed to the team of alright contributors.
Hope that the link shared by @vadolasi will help you figure out on making your feature added to alright.
Let us know if you will face any issues in the process of making your contribution.
Wish you the best of luck
Best regards Kalebu