0

How do I posible make this code work.. I am trying to figure it out lately. but my code doesnt seems to work Here is the code that I have tried on Button::before... The send button will on appear when I type or add image.. Sendkey.ENTER doesnt work on the site

THe code I have tried

xpath = '/html/body/div[1]/div/div[1]/div/main/div[1]/div/div/div/div[1]/div/div/div[3]/form/button'

        
        WebDriverWait(self.browser, self.delay).until(
            EC.presence_of_element_located((By.XPATH, xpath)))
        send = self.browser.find_element(By.XPATH, value=xpath)
        send.click()

I got this errors

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\support\wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
Backtrace:
        (No symbol) [0x00FAF243]
        (No symbol) [0x00F37FD1]
        (No symbol) [0x00E2D04D]
        (No symbol) [0x00E5C0B0]
        (No symbol) [0x00E5C22B]
        (No symbol) [0x00E8E612]
        (No symbol) [0x00E785D4]
        (No symbol) [0x00E8C9EB]
        (No symbol) [0x00E78386]
        (No symbol) [0x00E5163C]
        (No symbol) [0x00E5269D]
        GetHandleVerifier [0x01249A22+2655074]
        GetHandleVerifier [0x0123CA24+2601828]
        GetHandleVerifier [0x01058C0A+619850]
        GetHandleVerifier [0x01057830+614768]
        (No symbol) [0x00F405FC]
        (No symbol) [0x00F45968]
        (No symbol) [0x00F45A55]
        (No symbol) [0x00F5051B]
        BaseThreadInitThunk [0x7753FEF9+25]
        RtlGetAppContainerNamedObjectPath [0x77AF7BBE+286]
        RtlGetAppContainerNamedObjectPath [0x77AF7B8E+238]

1 Answers1

0

This form of xpath is unreliable and changing it could solve your issue. Assuming "Before" or "Send" is a text written on your button, you could try these xpath:

xpath = "//*[.='Before']" 

or

xpath = "//*[.='Send']"

If that doesnt work, inspect your page and look for CSS elements such as ID or class. (To see page code: right-click inspect, to focus on your element right-click inspect again on your element (button)) If you see class or IDs try the following with them as XPath:

xpath = "//*[@id='example-text']"

xpath = "//*[@class='put-your-class-string-here']"

If that doesn't solve the issue, could you share more information about the page element that you try to interact with? Or maybe just the HTML code of the button

CDJB
  • 14,043
  • 5
  • 29
  • 55
Dominik
  • 26
  • 5