Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Selenium-webdriver: Enter the text into the text area

Pic is attached for more detail please follow::![I want to enter the text in the text area: mentioned in photo][1][1]: https://i.sstatic.net/sai92.png I want to enter the text into text area but error is occur that element is not found. I have tried with X path, name and id but couldn't execute this code and want to play with other elements appeared on the page for the testing purpose but nothing!!! i don't know that it can be handle with java-executor or switch window (pop up).below mention is java code. How to handle this situation please help with full detail.

Java code:

@Test   
public void CreteLead() throws InterruptedException 
{
    WebElement _loginName = 
        driver.findElement(By.xpath(OR.getProperty("username")));

    _loginName.sendKeys(OR.getProperty("loginId"));

    WebElement _password = 
        driver.findElement(By.xpath(OR.getProperty("password")));
            _password.sendKeys(OR.getProperty("loginPassword"));
    WebElement _login = 
        driver.findElement(By.xpath(OR.getProperty("login")));

    _login.click(); 
    Thread.sleep(5000);

    WebElement _New = 
        driver.findElement(By.xpath(OR.getProperty("New")));

    _New.click();
    Thread.sleep(10000);
    driver.findElement(By.id("btnCreateCustomer")).click();

HTML code:

<table class="tbl_top_align" width="100%" cellspacing="3" cellpadding="0">
  <tbody>
    <tr>
    <tr>
    <tr>
    <tr id="trBranch">
    <tr id="trAssign">
      <td> Assign To*: </td>
      <td>
        <table cellspacing="0" cellpadding="0">
          <tbody>
            <tr>
              <td style="font-weight: normal !important;">
                <div 
                  id="ctl00_CPHPageContents_ctl00_CPHPageContents_ddlAssignedToPanel" 
                  class="RadAjaxPanel" style="display: block;"
                >
                  <span id="RequiredFieldValidator1" 
                    class="error_message" style="display:none;"
                  >* missing</span>
              </td>
              <td style="vertical-align: middle !important;">
              <td style="vertical-align: middle !important;"> Referral </td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
    <tr>
      <td style="padding: 4px 0 5px;"> Follow-up on: </td>
        <td style="padding: 4px 0 5px;">
          <a id="btnFollowUp" 
            href="javascript:__doPostBack('ctl00$CPHPageContents$btnFollowUp','')"
          >Not Scheduled</a>
        </td>
      </tr>
      <tr>
        <td> Account: </td>
        <td>
          <span id="ctl00_CPHPageContents_txtAccount_wrapper" 
            class="riSingle RadInput RadInput_Default" style="width: 160px;">
        </td>
      </tr>
      <tr>
        <td> Value: </td>
        <td>
          <span id="ctl00_CPHPageContents_txtAccountValue_wrapper" 
            class="riSingle RadInput RadInput_Default" style="width: 125px;">
        </td>
      </tr>
      <tr>
        <td>Description*:</td>
        <td>
          <textarea id="txtInstructions" class="schedule_notes" 
            style="height: 95px; width: 294px !important;" cols="20" rows="2"
            name="ctl00$CPHPageContents$txtInstructions"
          />
          <span id="RequiredFieldValidator2" class="error_message" 
            style="display:none;">* missing</span>
        </td>
      </tr> 
      <tr>
    </tbody>
  </table>
  <div class="action_buttons">
  </div>
like image 268
Adnan Ghaffar Avatar asked May 12 '26 02:05

Adnan Ghaffar


1 Answers

I had faced a similar issue with textarea, if you can sendkeys to the previous input field, just use TAB to move to next field (textarea) and enter text, it worked for me

driver.findElement(By.id("id_of_previous_input_field")).sendKeys(Keys.TAB,"This text will appear in textarea");
like image 139
Amith Avatar answered May 15 '26 01:05

Amith