I am testing the Lufthansa website with a Selenium webdriver test. The FROM field is already input with the string "Casablanca", so I click on it and I clear it. But the problem is that when I click on it again for a second time to write in an input, it is again automatically filled in with the input value "Casablanca". How can I fix this problem?
package Test;
// Generated by Selenium IDE
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class AirLineTest {
private WebDriver driver;
private Map<String, Object> vars;
JavascriptExecutor js;
@Before
public void setUp() {
driver = new ChromeDriver();
js = (JavascriptExecutor) driver;
vars = new HashMap<String, Object>();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void test() {
driver.get("https://www.lufthansa.com/ma/en/homepage");
driver.manage().window().setSize(new Dimension(1552, 840));
driver.findElement(By.xpath("//*[@id=\"cm-acceptAll\"]")).click();
driver.findElement(By.xpath("//input[@placeholder='From']")).click();
driver.findElement(By.xpath("//input[@placeholder='From']")).clear();
driver.findElement(By.xpath("//input[@placeholder='From']")).click();
driver.findElement(By.xpath("//input[@placeholder='From']")).sendKeys("Rabat");
driver.findElement(By.xpath("//input[@placeholder='To']")).click();
driver.findElement(By.xpath("//input[@placeholder='To']")).clear();
driver.findElement(By.xpath("//input[@placeholder='To']")).sendKeys("New York");
driver.close();
}
}