I want to add with python selenium framework, to input tag’s value
attribute equals let’s say New York, NY
. I guess I need for it, like driver.execute_script("arguments[0].setAttribute('value',arguments[1])",element, value)
but do not know how to use it. Any kind of support will be appreciated
<input type="text" role="combobox" aria-owns="react-autowhatever-1" aria-expanded="false" autocomplete="off" aria-autocomplete="list" aria-controls="react-autowhatever-1" class="StyledFormControl-c11n-8-82-0__sc-18qgis1-0 jxPUpE Input-c11n-8-82-0__sc-4ry0fw-0 qODeK react-autosuggest__input" placeholder="Enter an address, neighborhood, city, or ZIP code" aria-label="Search: Suggestions appear below" id="search-box-input" value="">
>Solution :
With reference to this code block
driver.execute_script("arguments[0].setAttribute('value',arguments[1])",element, value)
Where element is the input
element.
element=driver.find_element(By.CSS_SELECTOR, "input#search-box-input")
value is the text you would like to set here.
value='New York, NY'
So you can write in a single line
driver.execute_script("arguments[0].setAttribute('value',arguments[1])",driver.find_element(By.CSS_SELECTOR, "input#search-box-input"), 'New York, NY')