I am trying to have selenium click on the next page button at this site after clicking the submit button and getting pages of results: https://elibrary.ferc.gov/eLibrary/search
I have tried countless ways to have selenium click on this button. The html code for the next page button on the results page is here:
<button mat-icon-button="" type="button" aria-describedby="cdk-describedby-message-8" cdk-describedby-host="" aria-label="Next page" style="touch-action: none; user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span ><svg focusable="false" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></svg></span><div matripple=""></div><div ></div></button>
I've tried the following:
link = driver.find_element_by_xpath('//*[@id="rsltToolbar"]/mat-paginator/div/div/div[2]/button[2]')
link.click()
But the code does not work. Hopefully this is the button that needs to be clicked! I've tried by css selector, class_name, by javascript etc. to no avail. Any help much appreciated.
CodePudding user response:
link = driver.find_element_by_classname("mat-paginator-navigation-next")
should work fine
# (tested in js console with)
document.querySelector(".mat-paginator-navigation-next").click()
you might have to just add a delay (ie its probably not clickable initially(or clicking it too soon just does nothing)) I think you can wait for it to be clickable somehow