I'm trying to navigate through a website using Python and Selenium and I've run into an issue that I can't figure out how to solve (assuming it's even possible!)
<select id="uniqueid" autocomplete="off" value="10">
<option selected="selected" value="10">10</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
The above HTML code is used on the site for displaying the number of rows in a table of data which I'm trying to scrape. The total size of the table is just over 300 rows.
I've had no problem selecting one of the options using Selenium but what I was hoping to achieve was to manipulate the DOM and change the last value from 100 to 350 so that when my script selects that option the entire table is displayed without me having to iterate through the pagination.
I've read that I can use execute_script, but I don't know how to change the values of one of the options. For example:
WebDriver.execute_script("document.getElementById('uniqueid') --what text goes here-- = '350')
Any help would be most appreciated.
You can try this but understand that the site may not be OK with you sending whatever for a value. It may still limit the value to 100, etc.
The Javascript part just takes the element you passed it and sets the value to whatever you pass in, e.g. "300".
select = driver.find_element_by_id("uniqueid")
WebDriver.execute_script("arguments[0].value = arguments[1]", select, "300")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With