0

I'd like to click the button using python selenium but have failed to do so. How to click "나중에 하기" with a code? I've tried with driver.find_element_by_link_text but didn't work... please help

elem = driver.find_element_by_link_text('나중에 하기')
elem.send_keys(Keys.RETURN)

button class="aOOlW  bIiDR  " tabindex="0">설정</button"
button class="aOOlW   HoLwm " tabindex="0">나중에 하기</button"

1
  • 2
    please show more of your code, include the relevant html using snippet tool via edit and the url if possible. Commented Feb 26, 2019 at 5:17

2 Answers 2

1

find_element_by_link_text works only on <a> tags. Try to locate the element by xpath instead

driver.find_element_by_xpath('//button[.="나중에 하기"]').click()

Or use class instead to locate by text

driver.find_element_by_class_name('HoLwm').click()
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! Thank you so much!
0

You could try waiting for the element to be clickable and combine css selectors for tag and class

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.HoLwm"))).click()

imports

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.