Skip to content
Advertisement

Using selenium to click a button

For clicking a button with the following HTML code:

<a href="javascript:submitPage('V','All Notes','');" class="viewFilter">All Notes</a>

I have tried multiple ways to click/ access this button but to no success, for example:

all_notes = wait.until(EC.presence_of_element_located((By.XPATH, "//a[@href='javascript:submitPage('V','All Notes','');']"))).click()

all_notes = wait.until(EC.presence_of_element_located((By.XPATH, "//href[@type='class' and @value='View All']"))).click()

I am not really sure what the issue is here – for all other button presses on this webpage – selenium has been working appropriately. What other ways can I try?

Advertisement

Answer

all_notes = WebDriverWait(driver,10).until(EC.presence_of_element_located(
    (By.XPATH, '//*[@href="javascript:submitPage('V','All Notes','');"]'))).click()

escape the single quotes

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement