量角器通过名称标签获取元素
问题描述:
目前,我正在使用量角器和Selenium Web Driver.
Currently I am working with protractor and Selenium web Driver.
我有以下问题:
我有一个html页面,我使量角器单击一个按钮.然后弹出一个窗口.该窗口包含一个名称为描述"的文本框:
I have a html page, and I make protractor clicking a button. Then a window pops up. This window contains a text box with the Name "Description":
<input type="Text" name="Description" ... />
现在,当我尝试以下操作时:
Now when I try the following:
element(by.css('[name="Description"]')).sendKeys("rabbababab");
浏览器不执行任何操作,但是量角器不会引发错误.没有文本键入到文本框中.不幸的是,该名称是唯一可识别input-TextBox的方法.
The browser does nothing, but protractor does not throw an error. No text is typed into the TextBox. Unfortunatelly, the name is the only way to identfy the input-TextBox.
我在做什么错了?
答
直接按名称选择也可以:
Selecting directly by name works as well:
element(by.name('Description')).sendKeys("rabbababab");