I am using Python selenium to automate my attendance entry. It was working fine, now I wanted to try by modifying the source code. I have seen few posts stating that it can be modified using driver.execute_script()
and it works for JavaScript, but in my case I need to modify a source code under the select
tag. I was able to modify the source code using the inspect element
. The following is select
tags source code:
<select name="date1">
<option value="2016-09-17">2016-09-17</option>
<option value="2016-09-16">2016-09-16</option>
<option value="2016-09-14">2016-09-14</option>
</select>
I tried to do it with driver.execute_script()
. The following was my code:
sel = driver.find_element_by_xpath('/html/body/div[3]/div/div[2]/form/table/tbody/tr[2]/td[3]/select')
input_list = sel.find_element_by_tag_name('option')
cmd = "input_list.value = '2016-09-07'"
driver.execute_script(cmd)
But the above code is giving me the following error:
selenium.common.exceptions.WebDriverException: Message: input_list is not defined
I am able to modify the source code using the inspect element
window. Is there any way to modify the source code using selenium?