0

Not selecting from city field by using selenium webdriver and java language on Makemytrip application.

public class LoginPage {
    public static void main(String[] args) {


        System.setProperty("webdriver.chrome.driver", "chromedriver.exe");

        WebDriver driver = new ChromeDriver();
        driver.get("http://www.makemytrip.com/");
        driver.manage().window().maximize();
        driver.findElement(By.id("fromCity")).click();
    }
}

console error:

Exception in thread "main" org.openqa.selenium.WebDriverException: element click intercepted: Element input data-cy="fromCity" id="fromCity" type="text" class="fsw_inputField font30 lineHeight36 latoBlack" readonly="" value="Delhi"> is not clickable at point (244, 255). Other element would receive the click: div data-cy="outsideModal" class="loginModal displayBlock modalLogin dynHeight personal ">

Antony
  • 1
  • 4

2 Answers2

0

You can use below code to click as the thing that you are trying can be done by first moving the mouse pointer to that element and then click on that element .

So use below code :

WebDriver driver = new ChromeDriver();
driver.get("http://www.makemytrip.com/");
driver.manage().window().maximize();  
Actions action=new Actions(driver);
WebElement fromCity=driver.findElement(By.id("fromCity"));
action.moveToElement(fromCity).doubleClick().perform();
0

As per console error :element click intercepted.Another webelement with class that starts like loginmodal is expecting click.There is a login page or frame that is embedded onto main page.Hence element you are trying to click is hidden.

You can use the following to find no of frames

List frame=driver.findElements(By.tagname(‘iframe’)); System.out.println(“no of frames: ” + frame.size());

You can switch to frame with help of

driver.switchTo().frame(1);

After that handle login page and then switch to main page by

driver.switchTo().defaultContent();

This will redirect you to main page and then try locating web element you desire.