0

I'd like to click on the following link but it's not working:

<ul class="pagination pagination-large">
  <li style="display:inline;">
    <a name="Next" href="jamm/flavours/page=2" class="next">
      <span class="icon-navigate_next"></span>
    </a>
  </li> 
</ul>

My code

items = browser.find_elements_by_xpath("//ul[@class = 'pagination pagination-large']//li[@style ='display:inline;']")
print items
for k in items:
    print k
    k.click()
    print("clicked")
    k.send_keys(webdriver.common.keys.Keys.SPACE)
5
  • Share exception. Also share page URL if it's a public page Commented Nov 6, 2018 at 8:41
  • It simply passes does not click and its not a public page Commented Nov 6, 2018 at 8:42
  • Did you try to click link (<a>...</a>)? Commented Nov 6, 2018 at 8:43
  • yep I have tried everything Commented Nov 6, 2018 at 8:45
  • Accepted answer tells us that you haven't really tried everything as search by link @name/@class is the first thing you should have tried Commented Nov 6, 2018 at 9:15

2 Answers 2

1

I think the problem is the xpath you are using is not finding the element you need, in fact, it targets the list element, not the anchor.

Maybe you can try to identify the link by using the css class next instead:

items = browser.find_elements_by_class_name('next')
for item in items:
    item.click()

If it works now, you can either just use that if you don't have any other elements using it or you can fix your xpath.

Sign up to request clarification or add additional context in comments.

Comments

0

Try:

browser.find_elements_by_name('Next')

1 Comment

While this might answer the authors question, it lacks some explaining words and/or links to documentation. Raw code snippets are not very helpful without some phrases around them. You may also find how to write a good answer very helpful. Please edit your answer.

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.