Skip to content

Commit

Permalink
fix xpath for find_by_username
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalebu committed Sep 16, 2023
1 parent 4d50795 commit 91b430d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
}
Binary file added alright-video.mp4
Binary file not shown.
19 changes: 8 additions & 11 deletions alright/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def find_by_username(self, username):
EC.presence_of_element_located(
(
By.XPATH,
'//*[@id="app"]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[2]',
"/html/body/div[1]/div/div/div[4]/div/div[1]/div/div/div[2]/div/div[1]",
)
)
)
Expand Down Expand Up @@ -460,9 +460,7 @@ def send_message(self, message, timeout=0.0):
message ([type]): [description]
"""
try:
inp_xpath = (
'//*[@id="main"]/footer/div/div/span[2]/div/div[2]/div/div/div'
)
inp_xpath = '//*[@id="main"]/footer/div/div/span[2]/div/div[2]/div/div/div'
input_box = self.wait.until(
EC.presence_of_element_located((By.XPATH, inp_xpath))
)
Expand All @@ -489,13 +487,15 @@ def send_direct_message(self, mobile: str, message: str, saved: bool = True):
def find_attachment(self):
clipButton = self.wait.until(
EC.presence_of_element_located(
(By.XPATH, '//*[@id="main"]/footer//*[@data-icon="attach-menu-plus"]/..')
(
By.XPATH,
'//*[@id="main"]/footer//*[@data-icon="attach-menu-plus"]/..',
)
)
)
clipButton.click()

def send_attachment(self):

# Waiting for the pending clock icon to disappear
self.wait.until_not(
EC.presence_of_element_located(
Expand Down Expand Up @@ -671,7 +671,7 @@ def wait_until_message_successfully_sent(self):
"""wait_until_message_successfully_sent()
Waits until message is finished sending before continuing to next action.
Friendly contribution by @jeslynlamxy.
"""

Expand Down Expand Up @@ -700,14 +700,12 @@ def get_last_message_received(self, query: str):
query (string): query value to be located in the chat name
"""
try:

if self.find_by_username(query):

self.wait.until(
EC.presence_of_element_located(
(
By.XPATH,
'//div[@id="main"]/div[3]/div[1]/div[2]/div[3]/child::div[contains(@class,"message-in") or contains(@class,"message-out")][last()]',
"/html/body/div[1]/div/div/div[4]/div/div[1]/div/div/div[2]/div/div[1]/p",
)
)
)
Expand Down Expand Up @@ -772,7 +770,6 @@ def get_last_message_received(self, query: str):
header_group.get_attribute("data-testid") == "default-group"
and msg_sender.strip() in header_text.text
):

LOGGER.info(f"Message sender: {msg_sender}.")
elif (
msg_sender.strip() != msg[0].strip()
Expand Down

0 comments on commit 91b430d

Please sign in to comment.