Selenium WebDriver - Datadriven testing

143 views Asked by At

I am testing a website using Selenium Webdriver.

Eclipse has to fetch username from excel.

When the Username data in excel is xyz my test enters the username value twice, xyzxyz, into the form.

How can I fix it so that the data is entered only once.

Code is:

driver.findElement(By.id("username")).sendKeys("xyz");
1

There are 1 answers

0
AdrianHHH On

Add the following statement before the SendKeys line, so that the field is cleared before the filename is entered.

driver.findElement(By.id("username")). clear();

(Answer derived from a comment by @Subh.)