Kalebu / alright

Python wrapper for WhatsApp web-based on selenium
https://www.youtube.com/watch?v=yitQTt-NukM
MIT License
368 stars 110 forks source link

Updating the XPATH on find_by_username method #57

Closed euriconicacio closed 2 years ago

euriconicacio commented 2 years ago

As per issue #56, when trying to send a simple message, the execution hang forever and nothing happened. While debugging, it was noticed that the XPATH for the search_box on _find_byusername was not correct, probably due to an app update.

So, currently, this is incorrect:

            search_box = self.wait.until(
                EC.presence_of_element_located(
                    (By.XPATH, '//*[@id="side"]/div[1]/div/label/div/div[2]')
                )
            )

And this is correct:

            search_box = self.wait.until(
                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]')
                )
            )

In addition, seizing the PR, it is delivered a method for closing the browser after sending a message - it is advised, though, to drop a sleep after sending an image/video and before calling the method to close the browser, otherwise the message content will not be delivered correctly.

Since unit testing is not the procedure adopted on this repo, this code works perfectly with the up-mentioned change in the XPATH.