Textfield is not getting entered with proper data in selenium automation for IE browser

Hi All,

I'm trying automate the Appian application using selenium where I come across  a issue that data is not getting entered properly.

Have tried the following

1. using sendkeys function.

2. First clicking on textfield then clearing it after that entering the data.

Still I face issue.

Finally tried with JavaScript executeScript method to enter the data.

I can see same data is getting entered but when I click on save button.

Few textfield value is getting cleared.

Please anyone suggest best possible solutions.

  Discussion posts and replies are publicly visible

Parents Reply Children
  • public void trialIdentification(String eudraCTYear,String sequence,String checkDigit,String sponsorDate,String fullTitle, String sponsorNumber, String sponsorVersion,String fullAbbreviation) throws InterruptedException
    {
    String id,eudraCTYear_TextField=null,sequence_TextField=null,checkDigit_TextField=null,eudraCTYear_ID=null,sequence_ID=null,checkDigit_ID=null;


    APPLICATION_LOGS.debug("Generate 'Dynamic ID' for the EudraCT Text Fields");


    int i=0;
    for (WebElement eudract : EudraCT_TextFields)
    {
    id=eudract.getAttribute("id");
    if (i==0)
    {
    eudraCTYear_ID=id;
    System.out.println("PRINT EudraCTYear ID " +eudract.getAttribute("id"));
    eudraCTYear_TextField="//input[@id='"+id+"']";

    i++;
    }
    else if(i==1)
    {
    sequence_ID=id;
    System.out.println("PRINT Sequence ID " +eudract.getAttribute("id"));
    sequence_TextField="//input[@id='"+id+"']";
    i++;
    }
    else if(i==2)
    {
    checkDigit_ID=id;
    System.out.println("PRINT CheckDigit ID " +eudract.getAttribute("id"));
    checkDigit_TextField="//input[@id='"+id+"']";
    i++;
    }

    }

    driver.findElement(By.xpath(eudraCTYear_TextField)).click();
    /* driver.findElement(By.xpath(eudraCTYear_TextField)).clear();
    driver.findElement(By.xpath(eudraCTYear_TextField)).sendKeys(eudraCTYear);*/
    JavascriptExecutor js= (JavascriptExecutor)driver;
    js.executeScript("document.getElementById('"+eudraCTYear_ID+"').value='"+eudraCTYear+"'");

    APPLICATION_LOGS.debug("Enter 'EudraCT Year'");

    Thread.sleep(3000);





    driver.findElement(By.xpath(sequence_TextField)).click();
    /* driver.findElement(By.xpath(sequence_TextField)).clear();
    driver.findElement(By.xpath(sequence_TextField)).sendKeys(sequence);*/
    js.executeScript("document.getElementById('"+sequence_ID+"').value='"+sequence+"'");
    APPLICATION_LOGS.debug("Enter 'Sequence'");
    Thread.sleep(5000);


    driver.findElement(By.xpath(checkDigit_TextField)).click();
    /* driver.findElement(By.xpath(checkDigit_TextField)).clear();
    driver.findElement(By.xpath(checkDigit_TextField)).sendKeys(checkDigit);*/
    js.executeScript("document.getElementById('"+checkDigit_ID+"').value='"+checkDigit+"'");
    APPLICATION_LOGS.debug("Enter 'CheckDigit'");
    Thread.sleep(5000);


    id=FullTitleofTrial_textField.getAttribute("id");
    js.executeScript("document.getElementById('"+id+"').value='"+fullTitle+"'");
    Thread.sleep(5000);
    CT_Operational_Elements.waitForElement(FullTitleofTrial_textField).click();
    //CT_Operational_Elements.waitForElement(FullTitleofTrial_textField).sendKeys(fullTitle);
    APPLICATION_LOGS.debug("Enter 'Full Title'");
    Thread.sleep(5000);

    id=SponsorNumber.getAttribute("id");
    js.executeScript("document.getElementById('"+id+"').value='"+sponsorNumber+"'");
    Thread.sleep(5000);
    CT_Operational_Elements.waitForElement(SponsorNumber).click();
    // CT_Operational_Elements.waitForElement(SponsorNumber).sendKeys(sponsorNumber);
    APPLICATION_LOGS.debug("Enter 'Sponsor Number'");
    Thread.sleep(5000);

    id=SponsorVersion.getAttribute("id");
    js.executeScript("document.getElementById('"+id+"').value='"+sponsorVersion+"'");
    Thread.sleep(5000);
    CT_Operational_Elements.waitForElement(SponsorVersion).click();
    // CT_Operational_Elements.waitForElement(SponsorVersion).sendKeys(sponsorVersion);
    APPLICATION_LOGS.debug("Enter 'Sponsor version'");
    Thread.sleep(5000);


    id=FullAbbreviation.getAttribute("id");
    js.executeScript("document.getElementById('"+id+"').value='"+fullAbbreviation+"'");
    Thread.sleep(5000);
    CT_Operational_Elements.waitForElement(FullAbbreviation).click();
    //CT_Operational_Elements.waitForElement(FullAbbreviation).sendKeys(fullAbbreviation);
    APPLICATION_LOGS.debug("Enter 'Full Abbreviation'");
    Thread.sleep(5000);

    /* CT_Operational_Elements.waitForElement(Sponsor_DateField).clear();
    CT_Operational_Elements.waitForElement(Sponsor_DateField).click();*/

    id=Sponsor_DateField.getAttribute("id");

    js.executeScript("document.getElementById('"+id+"').value='"+sponsorDate+"'");
    Thread.sleep(5000);
    CT_Operational_Elements.waitForElement(Sponsor_DateField).click();
    // CT_Operational_Elements.waitForElement(Sponsor_DateField).sendKeys(sponsorDate);

    //CT_Operational_Elements.waitForElement(Sponsor_DateField).sendKeys(sponsorDate);
    APPLICATION_LOGS.debug("Enter 'Sponsor Date'");
    Thread.sleep(5000);


    CT_Operational_Elements.waitForElement(Save_Button).click();
    ReportUtil.report("Application Case Creation Page","Application Case Creation Page Validation","User should be able to save 'Trail indentication' case","Sucessfully saved 'Trail indentication' case","PASS");
    APPLICATION_LOGS.debug("Click on 'Save Button'");

    Thread.sleep(15000);



    try {

    Assert.assertEquals(driver.findElement(By.xpath(eudraCTYear_TextField)).getAttribute("value"),eudraCTYear);

    }catch(NoSuchElementException e)
    {
    ErrorUtil.addVerificationFailure(e);
    APPLICATION_LOGS.debug("CaseType not Found");
    ReportUtil.report("Application Case Creation Page","Application Case Creation page validation","Sucessfully entered EudracTYear ","Unable to Sucessfully enter EudraCtYear " + eudraCTYear,"FAIL");

    }

    try {

    Assert.assertEquals(driver.findElement(By.xpath(checkDigit_TextField)).getAttribute("value"),checkDigit);

    }catch(NoSuchElementException e){
    ErrorUtil.addVerificationFailure(e);
    APPLICATION_LOGS.debug("CaseType not Found");
    ReportUtil.report("Application Case Creation Page","Application Case Creation page validation","Sucessfully entered checkdigit ","Unable to Sucessfully enter checkdigit " + checkDigit,"FAIL");
    }
    try {

    Assert.assertEquals(driver.findElement(By.xpath(sequence_TextField)).getAttribute("value"),sequence);

    }catch(NoSuchElementException e)
    {
    ErrorUtil.addVerificationFailure(e);
    APPLICATION_LOGS.debug("CaseType not Found");
    ReportUtil.report("Application Case Creation Page","Application Case Creation page validation","Sucessfully entered sequence ","Unable to Sucessfully enter sequence " + sequence,"FAIL");

    }







    }


    }

    Have shared the method which i'm using.
  • Can you please let me know the issue and resolution?
    I'm new to selenium automation
  • Hi Sandeep,
    Have commented the method which will perform the input to textfield.
    Please go through it.
  • Hi Ravi,

    As far as i understood the issue, while running the automated script, the values are entered in the textfield but while navigating to next screen the values are not being saved.

    Please confirm if the saving of field values is working while tested manually?
  • Hi Farnaz,
    Manually data is getting saved. I have confirmed it.