python - Webdriver is unable to traverse by clicking on the next page button -
writing script in python in combination selenium purpose of scraping titles of different boutique shops in usa, when execute , results first page. results display across multiple pages. however, trouble comes when going next page clicking on next button in case right arrow key sign. neither clicks on button nor throws error. hope find here around it.
here partial script:
while true: element in wait.until(ec.presence_of_all_elements_located((by.xpath, "//div[@class='section-result-text-content']"))): name = element.find_element_by_xpath(".//h3[@class='section-result-title']/span") print(name.text) try: link in wait.until(ec.presence_of_all_elements_located((by.id, "section-pagination-button-next"))): link.click() except: break
elements in next page button lies:
<button ved="1i:2,t:12696,e:1,p:gbkwwa2qjofsvgstzldqda:664" aria-label=" next page " id="section-pagination-button-next" vet="12696" jstcache="673" jsaction="pane.paginationsection.nextpage" class="section-pagination-button noprint" jsan="7.section-pagination-button,7.noprint,0.ved,0.aria-label,0.id,0.vet,22.jsaction"><span class="section-pagination-button-next"></span></button>
after 'try' statement, selecting element using id in real not correct locator find desired element on ui. element trying access in 'span'.
try below code
for element in wait.until(ec.presence_of_all_elements_located((by.xpath, "//*[@id="section-pagination-button-next"]/span"))):
Comments
Post a Comment