Python Selenium - How to loop to the last
  • element in a site
  • 前端 未结 3 2043
    陌清茗
    陌清茗 2021-01-29 10:49

    I have created a python selenium script that should navigate through a website and collect people profiles (https://www.shearman.com/people). The program won\'t loop through the

    相关标签:
    3条回答
    • 2021-01-29 11:01

      You can try to use below line to click Next button

      driver.find_element_by_link_text(">").click()
      
      0 讨论(0)
    • 2021-01-29 11:07

      you can do it yourself :

      • ctrl+shift+i
      • right click on the next button -> inspect
      • right click on the next button code -> copy -> copy selector

      then you store the button in a WebElement nextButton then

      nextButton.click();
      
      0 讨论(0)
    • 2021-01-29 11:12

      If you look at the HTML of the element with image as >, it is the <a> tag within the last <li> tag of the <ul> tag. So to invoke click() on it you can use the following code block :

      driver.find_element_by_xpath("//ul[@class='results-pagination']/li[last()]/a").click()
      
      0 讨论(0)
    提交回复
    热议问题