I want Selenium to display a table with the maximum of rows. This is possible thanks to a button that allows to change the number of rows in the table. I have made a script :
url = 'http://www.side.developpement-durable.gouv.fr/EXPLOITATION/'
driver = webdriver.Chrome(executable_path=path_to_driver)
driver.maximize_window()
driver.get(url)
#I find the field where I want to execute my query
elem = driver.find_element_by_id("textfield")
#I write the text
elem.send_keys("photovoltaique")
#I send it
elem.send_keys(Keys.RETURN)
# I wait until ma page is loaded
WebDriverWait(driver, 15).until(EC.url_changes(url))
#I find the button to change my number of rows
elem = driver.find_elements_by_class_name("icon-arrow-bottom")
#I check the length of my object
print(len(elem))
#I click on the right button
elem[1].click()
This code is in a function called change_rows(url)
.
When I execute the script and call the function, this is what I receive as return :
- from the
print(len(elem))
: 1
When I execute manaully the instructions I get:
- from the
print(len(elem))
: 5
And I need the second element of my object elem
.
I tried with Firefox and Chrome webdriver.