简体   繁体   English

尝试使用watir-webdriver和chrome设置text_field时出错

[英]Error when trying to set text_field using watir-webdriver and chrome

I'm using cucumber with ruby and watir-webdriver. 我使用的是红宝石和watir-webdriver黄瓜。 I've not had this issue before and text_fields on other pages work fine. 我之前没有这个问题,其他页面上的text_fields也可以正常工作。 I've tried using CSS & name instead of ID but no luck. 我试过使用CSS和名称代替ID,但没有运气。 Does anyone have any ideas on what's causing this and how to get around it in Chrome? 是否有人对导致此问题的原因以及如何在Chrome中解决问题有任何想法?

The error does not occur when using Firefox. 使用Firefox时不会发生此错误。

Script: 脚本:

@session.text_field(:id, 'officialTitle').when_present.set("Test 1")

html: 的HTML:

<input id="officialTitle" name="official_title" server-validation="" class="form-control ng-pristine ng-invalid ng-invalid-required ng-touched" ng-model="profile.study.official_title" required="" type="text">

Error: 错误:

Selenium::WebDriver::Error::UnknownError: unknown error: a.tagName.toUpperCase is not a function
(Session info: chrome=46.0.2490.80)
(Driver info: chromedriver=2.17.340128
(994135a3538dd99439ef22cea8a9b098e00d8eb4),platform=Mac OS X 10.11.0 x86_64)

Turns out another element with the ID tagName was causing the issue, even though that element was not being interacted with. 导致另一个ID为tagName的元素引起了该问题,即使该元素未与之交互。 Changing that ID resolved my issues. 更改该ID可解决我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM