I would share the link here but I'm under NDA and requires login. The site does use "ant" and some other dynamic things but that doesn't cause any other issues. I've roughly 50 xpaths used for various items multiple pages including elements right around this target element.
The target is in a pagination. The goal is to get the last item that has a number (hit the last page in one click).
I'm using Python 3.7.2rc1 with Selenium 3.141.0. Currently only tested on Windows 10.
Let's say (like now) the pagination has four numbered buttons the xpath is:
I've tried many variations of which my current is (for the sake of testing):
All other xpaths work on this page. I used to click these via xpath all the time. It is a bot for a client.
The code I can share is:
try: self.site_XXXX_print("Looking for -> " + self.final_page_xpath) self.last_page_item = WebDriverWait(self.pbd, self.max_wait_time).until(EC.presence_of_element_located(By.XPATH(self.final_page_xpath))) except Exception as e: self.site_XXXX_print("FAILED FINDING LAST PAGE LINK ???")
I'd like to point out it says "LINK" because I was trying with the /a added but it didn't help and when it worked before clicking the LI itself worked fine. I'm almost ready to just dig up the event handler and call it directly.
self.final_page_xpath is currently the one above specifying @class
If I remove my try/except for my general error I get:
Looking for -> //li[contains(@class, 'ant-pagination-item')][last()] FAILURE: 'str' object is not callable ... ... ...
The line that causes this is:
self.last_page_item = WebDriverWait(self.pbd, self.max_wait_time).until(EC.presence_of_element_located(By.XPATH(self.final_page_xpath)))
After using this site to help me figure out bugs as a lurker over the years I've come to see it's picky with posts and I understand why. Please excuse me if my formatting is off or any details left out.
I have used this same sort of call repeated times in this project. All xpaths are set to variables ahead of time and due to the dynamic nature of the site I wait for all and while testing visually verify everything and tweak the timing if need be.