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 9083531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:47:47+00:00 2026-06-16T20:47:47+00:00

How can the cursor be focus on a specific input box on page load?

  • 0

How can the cursor be focus on a specific input box on page load?

The button is “Add new appointment” the script is:

<input type="button" onclick="open_win()" value="add new appointment"/>

 WebElement ek = driver.findElement(By.xpath("//input[@value='add new appointment']"));
 jse.executeScript("arguments[0].click();", ek); 

This opens a pop up window. Now I need to focus on the window.
Ajax is used to retrieve information from this pop up.
I tried every aspect to focus on the new pop up. The input txt fields are hidden, The code that I’ve tried is:

jse.executeScript("window.focus();");

driver.switchTo().defaultContent();

driver.switchTo().activeElement().findElement(By.xpath("//*[@id='barge:bargeId:txtInput']"));

driver.switchTo().alert();

I thought to focus on the text field with the following code:

jse.executeScript("document.getElementById('barge:bargeId:txtInput')[0].setAttribute('type', 'text');");
                driver.findElement(By.xpath("//*[@id='barge:bargeId:txtInput']")).sendKeys("suxs");

This also haven’t worked.
Even jse.executeScript("document.title") has not worked.
the code for text field

<span id="barge:bargeId:input">
  <input id="barge:bargeId:txtInput" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all inputbox doubleInputbox ui-state-hover" type="text" tabindex="" maxlength="17" accesskey="" name="barge:bargeId:txtInput" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"/>
</span>
  • 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-16T20:47:48+00:00Added an answer on June 16, 2026 at 8:47 pm
    1. to click on the button you can simple do this: driver.findElement(By.xpath("//input[@value='add new appointment']")).click();

    2. By saying “This opens a pop up window” do you mean an actual new window, new tab or dialog like this or like this?

    I think it opens up the dialog, and in this case usually it’s just another element on the page. And in this case this should work:

    driver.findElement(By.xpath("//*[@id='barge:bargeId:txtInput']")).sendKeys("suxs");
    

    UPDATE:
    Since it’s a new window, there ways to switch to the new window described here:

    driver.switchTo().window("windowName");
    

    Also, it would be helpful to check the code of open_win() javascript function.

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

Sidebar

Related Questions

I can get the actual position of the cursor in an input field. How
How can I programmatically assign focus to a specific UITextField in a view? I
i have search form in my page. On page load it is on focus
I have a script where i can just click on a div and add
In Vim, ^ can move the cursor to the first word (non white space)
I can get the word under the cursor with or , and I can
how can I set the mouse cursor position in an X window using a
How can I get a transparent cursor using Python GTK3 and pyGObject. I have
I can't figure out the problem on my code : /* Declare a cursor
How can I change behavior of how items are selected in QGridLayout by cursor

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.