• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic