【发布时间】:2023-03-15 12:01:01
【问题描述】:
我在 rspec 和 spec 文件中使用 selenium:
wait.until { driver.find_element(:id => "data_source_type_name") }
RuleDesc = driver.find_element(:id, "data_source_type_name")
RuleDesc.send_keys "Mobility"
在 html 中我有:
<div class="col-sm-9">
<input class="form-control" type="text" id="data_source_type_name" name="data_source_type[name]" required="">
</div>
实际上在 Bootstrap 模式下(即仅在单击按钮后可见)我模拟了单击。它显示具有特定 div 的模式,但我收到以下错误:
[remote server] file:///tmp/webdriver-profile20150119-6088-50uggo/extensions/fxdriver@googlecode.com/components/command-processor.js:8991:in `fxdriver.preconditions.visible': Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotVisibleError)
编辑:当我打印 puts RuleDesc.displayed?它返回 false,但在 webdriver 中它正在显示。
【问题讨论】:
-
你能试试这个吗,
find(:xpath, "//*[contains(@id, 'data_source_type_name')]") -
我尝试的每个选择器都返回相同的结果,除了 driver.execute_script("document.getElementById('data_source_type_name').value ='Test value';") 确实有效,但我不想使用 javascript跨度>
标签: ruby-on-rails ruby selenium rspec