Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:42:06+00:00 2026-06-03T02:42:06+00:00

I am trying to perform some automated tests on a JSF page that is

  • 0

I am trying to perform some automated tests on a JSF page that is already deployed on the internet and i cannot modify currently.

I know how the source looks like and i see that some of the fields do not have id or name, this is how its source looks like:

<h:form rendered="#{messagePusher.userName == null}"> 
               <h:messages style="color: red"/>
               Nickname:                       
                <h:inputText id="inputName" value="#{messagePusher.userName}" required="true" requiredMessage="Enter your name!!!"/>
                <br/>
                <h:commandButton action="#{messagePusher.renderChat()}" value="ENTER CHAT"/>               

        </h:form>


        <h:panelGrid id="chatpanel" columns="1" border="0" rendered="#{messagePusher.userName != null}">

            <br/>  
            <h:dataTable value="#{chatMemoryResourse.messages}" var="current">
                    <h:column>
                        <h:outputText value="#{current.message} #{current.sentDateNTime}"
                                      style="color: blue"/>
                    </h:column>
                </h:dataTable>
                <h:form> 
                    <h:messages style="color: red"/>
                    <h:inputText id="input" value="#{messagePusher.messageText}" required="true" requiredMessage="VALUE REQUIRED!"/>
                    <br/>
                    <h:commandButton action="#{messagePusher.writeMessage()}" value="Send message" />
                </h:form>

        </h:panelGrid>

Because there is no way for me to give the ids to selenium i decided to manually inspect the elements in the browser and use the ids that the browser tells me. So when i analyze the page source from my chromes console i see this things like this:

input id=”j_idt8:inputName” name=”j_idt8:inputName” type=”text”

So far so good.
I start writing some selenium test for the first of the fields and when i test it seem to work.

selenium.start();
selenium.open(BASE_URL);    
selenium.type("j_idt8:inputName", "Robot"); 
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
selenium.click("j_idt8:_t12");
...

The problem is in the next field it doesn’t detect it. I dont know why.
I get this:

Exception in thread “main”
com.thoughtworks.selenium.SeleniumException: ERROR: Element
j_idt17:input not found at
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
at
com.thoughtworks.selenium.DefaultSelenium.type(DefaultSelenium.java:317)
at chattester.ChatTester.main(ChatTester.java:24)

So as you see this is some kind of chat room, the first input sets nickname and the second is used to input test into the chat. The page has 2 forms when the first value is entered the first form hides and the second appears(the page is refreshed).

The second form has an input field that sends a message to a server and the server uses ajax reverse technology to update all clients. I don’t know if is there some kind of limitation with Selenium when interacting with AJAX.

Here i paste the rest of the test code the only thing that works is when testing the first form:

public class ChatTester {

private static final String MAX_WAIT_TIME_IN_MS = "60000";
private static final String BASE_URL = "http://somedemoapplication/";    

public static void main(String[] args) {

    Selenium selenium = new DefaultSelenium("localhost", 4444, "*firefox", BASE_URL);
    selenium.start();
    selenium.open(BASE_URL);    
    selenium.type("j_idt8:inputName", "Robot");         
    selenium.click("j_idt8:_t12");


        selenium.type("j_idt17:input", "Selenium testing in proggress....");  
        selenium.click("j_idt17:_t20");
        selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);

    selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
    selenium.type("j_idt17:input", "Test over!");  
        selenium.click("j_idt17:_t20");
    selenium.stop();


}     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:42:08+00:00Added an answer on June 3, 2026 at 2:42 am

    Try this code:

    Selenium selenium = new DefaultSelenium("localhost", 4444, "*firefox", BASE_URL);
    selenium.start();
    selenium.open(BASE_URL);    
    selenium.type("j_idt8:inputName", "Robot");         
    selenium.click("j_idt8:_t12");
    selenium.waitForCondiditon("selenium.isElementPresent('j_idt17:input')", MAX_WAIT_TIME_IN_MS);
    selenium.type("j_idt17:input", "Selenium testing in proggress....");  
    selenium.click("j_idt17:_t20");
    selenium.waitForCondiditon("selenium.isElementPresent('j_idt17:input')", MAX_WAIT_TIME_IN_MS);
    selenium.type("j_idt17:input", "Test over!");  
    selenium.click("j_idt17:_t20");
    selenium.stop();
    

    Instead of waiting for element present you can wait for ajax too:

    selenium.waitForCondition("selenium.browserbot.getCurrentWindow().jQuery.active == 0;", MAX_WAIT_TIME_IN_MS);
    

    Some materials on xpath and css: w3 xpath spec, xpath examples, CSS selectors

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify all links on a page so they perform some additional
I'm trying to parse a large csv file and perform some operations on that
I am trying to write MSBuild script that will perform some action (eg. print
I have a Rails 3 app that is trying to perform some controller action
I'm trying to perform some memory profiling on an applications that is accumulating large
I was trying to create simple program that would perform some trivial operation with
I'm trying to write a custom Rake task to perform some tests for a
I am trying to perform some work in a separate thread and stop that
I currently have a macro that uses a form in order to perform some
I am trying to perform some composition-based filtering on a large collection of strings

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.