【问题标题】:How to find and write inside an input tag with selenium python如何使用 selenium python 在输入标签内查找和写入
【发布时间】:2019-07-23 05:58:48
【问题描述】:

我想将网站https://www.tradingview.com/chart/ 中值为20 的输入标签的值更改为110。我怎么能做到这一点?(所有这些都使用 selenium python) 我想更改它的 MA Length 在 Vol 中的值,您可以通过单击网站左上角 Apple Inc - D - Cboe BZX 正下方的 Vol(20) 来访问它。

【问题讨论】:

  • 单击Vol(20) 不会弹出弹出窗口。涉及任何进一步的步骤?可能您需要一组有效的凭据。你有演示集吗?

标签: python selenium automated-tests


【解决方案1】:
  1. 使用您的favourite browser developer tools找到您想要与之交互的元素

  2. 选择一个合适的Locator Strategy,这将允许唯一匹配页面上的元素
  3. Locate the element
  4. 将定位代码包装成Explicit Wait 这样your test will be more robust and reliable
  5. 使用WebElement API 与元素交互

示例代码:

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)

【讨论】:

猜你喜欢
  • 2019-12-01
  • 2021-06-16
  • 1970-01-01
  • 1970-01-01
  • 2019-12-10
  • 1970-01-01
  • 2021-06-28
  • 1970-01-01
  • 2020-09-18
相关资源
最近更新 更多