Issue
I used send automated messages to various whatsApp users using this xpath code to click on the send button.
navegador.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]').send_keys(Keys.SEND)
It recently stopped working saying that it can't find the xpath.
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="main"]/footer/div[1]/div[2]/div/div[2]/button"} (Session info: chrome=91.0.4472.124)
I've tried updating the xpath as it seams to have changed to:
//*[@id="main"]/footer/div[1]/div[2]/div/div[2]/button
But I still get the same error message.
I've also seen one thread suggesting that the driver may not be set for the current page. If so, how do I fix that? selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=81.0.4044.138)
What am 'I missing?
Thanks in advance for any help on this mater.
Solution
Possibly your locator is not correct.
Also, the send element button appears with a short delay after the text is inserted into the message text area.
Try this:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 20)
wait.until(EC.visibility_of_element_located((By.XPATH, '//span[@data-testid="send"]'))).click()
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.