I work with a CMS where I have to change a user status from "Pending" to "Confirmed". If I do it manually I have to click on a dropdown value. There are 12 dropdowns on the page the dropdown value is always the same. Then I have to refresh the browser and click through the next 12 dropdowns.
I wrote this Python script with Selenium:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
import time
options = Options()
options.add_argument("user-data-dir=selenium")
driver = webdriver.Chrome(options=options)
driver.get("https://url.com")
select = Select(driver.find_element_by_class_name('address-status'))
select.select_by_value('1')
time.sleep(1)
driver.close()
This is the html for the dropdown:
<select name="data[status]" class="address-status" data-id="44980" id="status">
<option value="2">Post card sent</option>
<option value="1">Confirmed</option>
<option value="0" selected="selected">Pending</option>
</select>
My problems which I can't figure out on my own are:
The script only selects the first class of 'adress-status' and selects the value I want but then it stops. But there are 11 more identical classes/dropdown menus where the (same) value has to be selected.
I don't know how to refresh the page to get the next set of dropdowns and restart the selection process/script.
I figured out that I may have to loop parts of the script but I learned and used Python for the first time yesterday and I just can't figure it out in time for this task.