本文介紹了如何使用 selenium python 在輸入標簽中查找和寫入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想將網站 我想更改它的 MA Length 在 Vol 中的值,您可以通過單擊網站左上角 Apple Inc - D - Cboe BZX 正下方的 Vol(20) 來訪問它.
解決方案
使用
- 選擇一個合適的 定位器策略,這將允許唯一地匹配元素頁面
- 定位元素
- 以這種方式將定位代碼包裝到 顯式等待中 您的測試將更加穩健和可靠
- 使用 WebElement API 進行交互帶元素
示例代碼:
driver.get("https://www.tradingview.com/chart/")WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "http://a[contains(@class,'format')]"))).click()輸入 = WebDriverWait(驅動程序,10).until(EC.element_to_be_clickable((By.XPATH, "http://input[contains(@class,'innerInput')]")))driver.execute_script("arguments[0].value=30", 輸入)
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 selenium python) The value i would like to change it's MA Length inside Vol, you can acess that by clicking at Vol(20) right below Apple Inc - D - Cboe BZX at the top left part of the website.
解決方案
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, "http://a[contains(@class,'format')]"))).click()
input = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "http://input[contains(@class,'innerInput')]")))
driver.execute_script("arguments[0].value=30", input)
這篇關于如何使用 selenium python 在輸入標簽中查找和寫入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!