0

I need to click the "next" button on the following page:

https://www.amazon.com/gp/goldbox/ref=gbps_ftr_s-4_bedf_wht_29726380?gb_f_deals1=dealStates:AVAILABLE%252CWAITLIST%252CWAITLISTFULL%252CEXPIRED%252CSOLDOUT%252CUPCOMING,includedAccessTypes:,sortOrder:BY_SCORE,enforcedCategories:2972638011&pf_rd_p=afc45143-5c9c-4b30-8d5c-d838e760bedf&pf_rd_s=slot-4&pf_rd_t=701&pf_rd_i=gb_main&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=60XTK6YDM9WEAFXB6519&ie=UTF8

I have the following code that will not find xpath element for the "next button":

browser.find_element_by_xpath("//ul[@class='a-pagination']/li[@class='a-last']/a").click() # Click on next button

I have also tried this variation:

browser.find_element_by_xpath("//div[@id='pagination-next-6885645543374035']/ul/li[@class='a-last']/a")

I also tried directly copying the xpath from the inspector. Neither of these three options work.

Thanks in advance for your help.

3
  • Have you tried browser.find_element_by_id('args')? Or are you specifically wanting to use xpath? Commented May 24, 2018 at 21:06
  • I'm up for anything that works. Do you have an example based on the html structure? Thanks! Commented May 24, 2018 at 21:48
  • I will show you how to do it today when I get off work Commented May 25, 2018 at 13:14

1 Answer 1

0

The issue is Amazon attaches a numerical ending onto the ID that is different each time the page loads. Finally found a way to select it using xpath:

browser.find_element_by_xpath("//span[@class='a-declarative']/div[2]/ul/li[@class='a-last']/a")
Sign up to request clarification or add additional context in comments.

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.