Selenium Webdriver sendKeys method sending value twice



  • I have 6 selenium tests (TestNG) running on chrome and firefox (both up to date versions) which connect to Browser stack to run.

    the problem is that 1 of the test fails intermittently on Chrome as the sendKeys method is entering the email twice after clearing the text field. (i have seen that field gets cleared successfully in the test run)

    problem - value entered twice: test@test.comtest@test.com.

    the tests run on gocd (like Jenkins) every morning. it only fails when run on gocd but when testing on my intellij these tests are always passing.

    this is my code to clear and send the text

     private void editTextField(String textToInput, WebElement element) {
                element.clear();
                element.sendKeys(textToInput);
        }
    
            public void editPassengerDetails(String name, String lname, String email) {
            waitForPageCheckOutPageToLoad();
    
            openPassengerDetailsBox.click();
    
            editTextField(name, emailFirstName);
    
            editTextField(lname, emailLastName);
    
            editTextField(email, emailAddress);
    }
    

    test

    checkoutPage.editPassengerDetails("Testfnames", "Testlname", "test@test.com");
    

    can someone see anything wrong with this?



  • Make sure that before sending the text,filed is clearing properly. add assert before sendkeys to make sure that text field is empty



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2