开发者

Selenium input text not working in JSF

I have some page in JSF2.0 where I need to validate fields. This is cross-field validation, so I binded fields to UIComponents. All three fields are <h:inputText> so all are binded to HtmlInputText.

Validation method just reads values from all the HtmlInputTexts. It works pretty well when I run the app and use it by hand. Problem is it doesn't work when selenium inputs values. Part of selenium code is开发者_如何学JAVA:

selenium.type("identifier=myForm:myTextField", "someText");

So it inputs text into the text field. It works and I can see text is really there. But when I debug validation method, which reads values from UIComponents, the value is null after clicking "Submit". It is not null when entered by hand, only when selenium enters it.

Why is that? Why selenium doesn't work? It does pretty the same I do by hand, yet it works by hand, doesn't work by selenium.


Note that JSF-generated IDs are usually not the ID you have assigned. For example myTextField in a form called myForm will have an ID myForm:myTextField


As JSF takes charge of ID's I prefer setting an 'unique id' in the styleClass attribute which is rendered as class. Then you select the input with that class.

You may have more than the 'unique id' on an element. Then I prefer to search for an element with a class that contains the 'unique id'. It lets you change styling without changing the test.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜