This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes How can I use Webdriver (Selenium2) locator By.id to locate PrimeFaces autogenerated ID's with Colon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How can I use Webdriver (Selenium2) locator By.id to locate PrimeFaces autogenerated ID Watch "How can I use Webdriver (Selenium2) locator By.id to locate PrimeFaces autogenerated ID New topic
Author

How can I use Webdriver (Selenium2) locator By.id to locate PrimeFaces autogenerated ID's with Colon

Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
When trying to send text to a TextBox created via PrimeFaces:

I try:

getDriver().findElement(By.id("addRowTable:0:hostName")).sendKeys("testing");

Html is:

<HTML>
<label>Enter Hostname:</label><script id="addRowTable:0:j_idt474_s" type="text/javascript">$(function() {PrimeFaces.cw('Watermark','widget_addRowTable_0_j_idt474',{id:'addRowTable:0:j_idt474',value:'Hostname',target:'addRowTable:0:hostName'},'watermark');});</script>
<span class="zoneName"><input id="addRowTable:0:hostName" name="addRowTable:0:hostName" type="text" maxlength="254" size="20" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" /><script id="addRowTable:0:hostName_s" type="text/javascript">PrimeFaces.cw('InputText','widget_addRowTable_0_hostName',{id:'addRowTable:0:hostName'});</script>.xxxxcxxxxxdddddddddd.net</span></td>

</HTML>

I get the XPath as:

//*[@id="addRowTable:0:hostName"]

I get exception:

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"addRowTable\\:0\\:hostName"}
Command duration or timeout: 149 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

When i look at

http://seleniumhq.org/exceptions/no_such_element.html

i get a generic explanation:

The element may not be present.

Even Escaping : with \\ did not work

getDriver().findElement(By.id("addRowTable\\:0\\:hostName")).sendKeys("testing");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I use Webdriver (Selenium2) locator By.id to locate PrimeFaces autogenerated ID's with Colon
 
Similar Threads
Is it possible to put a button inside autocomplete in jquery ui plugin?
jQuery select option
Javascript call bean setter
PrimeFaces Newbie: How to control content on page?
How to control JSF to stop prefix value with UI Component Identifer