1

I am working with python and selenium to click on the Upload button on a facebook page. The HTML associated with this seems to have a within a table tag. The html is as in the following image. The button circles is the one I am trying to press.

Can anyone please tell me how should I press this button? I am using Python 3.7

enter image description here

2
  • are you only want to click on upload button Commented Jan 1, 2020 at 8:26
  • Yes, only the upload button. Commented Jan 1, 2020 at 8:29

1 Answer 1

1

There is a multiple way to click on button you can try any of one

By using Xpath without wait: try: driver.find_element_by_xpath('your Xpath').click() print('Button clicked ok') except Exception as e: print('Error in clicking BTN : ' + str(e))

By using Xpath with wait:

try:
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
        (By.XPATH, 'your Xpath'))).click()
    print('Button clicked ok')
except Exception as e:
    print('Error in clicking BTN : ' + str(e))

By using Css selector:

try:
        driver.find_element_by_css_selector('a._3m1z').click()
        print('Button clicked ok')
    except Exception as e:
        print('Error in clicking BTN : ' + str(e))

By using css selector with wait:

try:
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
        (By.CSS_SELECTOR, 'a._3m1z'))).click()
    print('Button clicked ok')
except Exception as e:
    print('Error in clicking BTN : ' + str(e))

you can copy xpath by right click on element >>copy>>xpath

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer, and I'm using the third option, but that opens a win32 browse file. I am unable to use send_keys functions. Please see the question at this link: stackoverflow.com/questions/59558106/…
you welcome if this help you accept my answer that will helps other..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.