I am new to Python and Selenium, but starting to pick it up. I was looking for ways to solve this problem, but I can not find the exact solution.
What I'm trying to do is click on all the links to the username on the page, click the "Next" button on the page that I took to, then return to the original page and do the same for the rest of the link username.
Basically, I want to create a loop that does this:
- click on the first username
- click on the button
- return to previous page
- click on the second username
- click on the button
- return to previous page
ETC ..... through each link
Here is my current code and what I have tried so far:
from selenium import webdriver from selenium.webdriver.common.keys import Keys browser = webdriver.Firefox() browser.get('thewebpage') search = browser.find_element_by_id('getSearch') search.click() search.send_keys('searchitem' + Keys.RETURN) searchitem = browser.find_elements_by_class_name("name")[0] searchitem.click()
The program ends and nothing happens on the screen. There is no error message.
What should I change to click each link on the homepage and click the button on the linked pages?
Here is a link to a similar problem. Link scrolling through Selenium Webdriver (Python)
Your help is greatly appreciated.
source share