I was trying to Automate the giftcard page of spicejet.com . I have debug the Xpath manually in Chrome console for “Birthday” link webelement under “E-GIFT CARD” main linktext webelement and used Explicit wait at required place but still I am getting below Expection :
Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //ul//li//a[@style='height: 30px;' and text()='Birthday' and @class='ng-binding']/preceding::span[1] (tried for 30 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "D:\\Software\\LatestDownloadedSoftware"
+ "\\SELENIUMWEBDRIVER\\Webdrivers\\Drivers\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://book.spicejet.com/LoginCorporateAgent.aspx");
WebElement giftcard=driver.findElement(By.xpath("//a[@href='https://spicejet.woohoo.in' ]"));
Actions acn=new Actions(driver);
acn.moveToElement(giftcard).click().build().perform();
WebDriverWait wait=new WebDriverWait(driver,30);
WebElement egiftcard=wait.until((ExpectedConditions.visibilityOfElementLocated(By.xpath("//ul//li//a[@style='height: 30px;' and text()='Birthday' and @class='ng-binding']/preceding::span[1]"))));
WebElement birthday=wait.until((ExpectedConditions.visibilityOfElementLocated
(By.xpath("//A[@href='https://spicejet.woohoo.in/birthday'][text()='Birthday'][text()='Birthday'])[2]"))));
acn.moveToElement(egiftcard).moveToElement(birthday).click().build().perform();