How To Find And Write Inside An Input Tag With Selenium Python
I would like to change a value of a input tag that haves the value 20 to 110 in the website https://www.tradingview.com/chart/. How can I actually do that?(all of that using seleni
Solution 1:
Locate the element you would like to interact with using your favourite browser developer tools
- Choose an appropriate Locator Strategy which will allow to uniquely match the element at the page
- Locate the element
- Wrap the locating code into an Explicit Wait this way your test will be more robust and reliable
- Use WebElement APIs to interact with elements
Example code:
driver.get("https://www.tradingview.com/chart/")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(@class,'format')]"))).click()
input = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[contains(@class,'innerInput')]")))
driver.execute_script("arguments[0].value=30", input)
Post a Comment for "How To Find And Write Inside An Input Tag With Selenium Python"