0

In site goIndigo and navigating to View/Change booking and selecting E mail itenary , a pop comes , I want to close that Pop up using Close button in Pop up:

But I am getting Error that Element is not visible;

My code is as below:

WebDriver drv= new FirefoxDriver();
drv.get("https://book.goindigo.in/?wt_mc=googlesearch.brand&gclid=CjwKEAjwxoG5BRCC7ezlzNmR8HUSJAAre36jSbKPBIdunIi2WUecy4wVPCFnqTv73JMeG95oUjTquxoCRlPw_wcB");
drv.findElement(By.xpath("//a[text()='Flight Status']")).click();
drv.findElement(By.xpath("//a[text()='View / Change Booking']")).click();
drv.findElement(By.xpath("//input[@id='indiGoRetrieveBooking_RecordLocator']")).click();
drv.findElement(By.xpath("//input[@id='indiGoRetrieveBooking_RecordLocator']")).sendKeys("abcdef");
drv.findElement(By.xpath("//input[@id='indiGoRetrieveBooking_EmailAddress']")).sendKeys("pandey");
drv.findElement(By.xpath("//input[@id='emailButtonId']")).click();
String mainhandle = drv.getWindowHandle();
WebElement from =drv.findElement(By.xpath("//div[@class='buttonGlbl']"));
from.click();
Curious
  • 282
  • 4
  • 21
Testerone
  • 1
  • 1
  • ur work flow is not clear, after going to ur site, than i enter booking reference and email/last name, than i click on email itenary and the pop up opens. u want to close that pop up? – noor Apr 29 '16 at 08:43

2 Answers2

0

First try to put Thread.sleep() before you look for element, just to wait for element arise. It is quick solution just to check if the problem is too fast execution:

drv.findElement(By.xpath("//input[@id='emailButtonId']")).click(); String mainhandle = drv.getWindowHandle(); Thread.sleep(2000); WebElement from =drv.findElement(By.xpath("//div[@class='buttonGlbl']"));

Then if everything is ok, you can change from sleep() to more nice solution:

WebDriverWait wait = new WebDriverWait(drv, 10); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='buttonGlbl']")));

kotoj
  • 769
  • 1
  • 6
  • 25
  • You can also set implicityWait to avoid situation like that at any place of your site: `drv.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);` – kotoj Apr 29 '16 at 08:53
0

i assume that, ur close pop up comes up.

if u want to close that pop up, just use

Thread.sleep(1000);
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("$('#emailItinerarySuccessModal .indigo-submit').click();");
noor
  • 2,954
  • 2
  • 16
  • 29
  • Can you also explain how did come to know the X path? (''$('#emailItenarySuccessModal.indigo-submit').click:"); usually we use javascript executor for scrolling window ryt? – Testerone Apr 30 '16 at 10:00
  • By javascript u can do click , change attrbute value also...and if this works pls accpt the answer...thanks....:) – noor Apr 30 '16 at 10:13
  • Thanks again :) , Can you give me any link where I can study how to find X path using javascript . – Testerone May 02 '16 at 06:23