Not able to identify datepicker in chrome for my site "tui.co.uk".

0 votes

package co.tui.uk;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.interactions.ClickAction;

import org.openqa.selenium.remote.server.handler.SendKeys;

public class Day2 {

     WebDriver driver;

     public void invokeBrowser()

     {

    try {

System.setProperty("webdriver.chrome.driver", "C:\\Users\\extad7\\Downloads\\vAMSHI\\Chrome\\chromedriver.exe");

driver  = new ChromeDriver();

driver.manage().deleteAllCookies();

driver.manage().window().maximize();

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

driver.manage().timeouts().pageLoadTimeout(100, TimeUnit.SECONDS);

driver.get("https://www.tui.co.uk/");

searchHolidays();

} catch (Exception e) {

e.printStackTrace();

}

     

     }

     

    public void searchHolidays()

    {

    driver.findElement(By.id("airports")).click();

   

    driver.findElement(By.id("tui_widget_searchpanel_views_CheckBox_1")).click();

    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

   

    driver.findElement(By.name("units[]")).sendKeys("spain");

    driver.findElement(By.name("when")).click();

    driver.findElement(By.id("icon-v2 icon-TUI_Calendar")).click();  ..  [Executing till this line]

    driver.findElement(By.xpath("//*[@id=tui_widget_searchpanel_views_DepartureDate_0]/div[2]/div/div[2]/div/div[2]/table/tbody/tr[4]/td[5]/i"));

   (Not able to pick date after coming to calender):  

    driver.findElement(By.id("tui_widget_searchpanel_views_SubmitButton_0")).click();

   

   

    }

     

public static void main(String[] args) {

Day2 myobj = new Day2();

myobj.invokeBrowser();

}

}

May 20, 2018 in Selenium by Vamshi
53 views

1 answer to this question.

0 votes

Dear Vamshi,

After clicking on the date box you just need to pick the required date. You do not need the following piece of code since this code is again identifying the date box itself.

Syntax: 

 driver.findElement(By.id("icon-v2 icon-TUI_Calendar")).click();

According to your code 

You have already identified the datebox via "id=when" and clicked on it.  If you identify the date box again and click on it  for the second time the calendar will disappear. That is the reason your Selenium is unable to pick the date. Moreover ,After identifying the date you need to click on it. So , I would request you to please try the below code. 

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class Day2

{

public static WebDriver driver= null;

public void invokeBrowser()

{

try

{

System.setProperty("webdriver.chrome.driver","D:\\SeleniumFiles\\Selenium\\Drivers\\chromedriver.exe");

driver= new ChromeDriver();

driver.manage().timeouts().pageLoadTimeout(20,TimeUnit.SECONDS);

driver.get("https://www.tui.co.uk");

driver.manage().window().maximize(); 

driver.manage().deleteAllCookies();

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

searchHolidays();

}

catch (Exception e)

{

e.printStackTrace();

}

  }

  public void searchHolidays() throws InterruptedException

{

driver.findElement(By.id("airports")).click();

    driver.findElement(By.id("tui_widget_searchpanel_views_CheckBox_1")).click();

    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

    driver.findElement(By.name("units[]")).sendKeys("spain");

    Thread.sleep(5000);

    driver.findElement(By.xpath("//input[@id='when']")).click(); 

    Thread.sleep(5000);

    driver.findElement(By.xpath("//div[@class='month-navigator']/following-sibling::div/table/tbody/tr[5]/td[3]/i")).click();;  

    driver.findElement(By.id("tui_widget_searchpanel_views_SubmitButton_0")).click();

    System.out.println("Successfully picked the date.");

}

public static void main(String[] args)

{

Day2 myobj = new Day2();

myobj.invokeBrowser();

}

}

Please try to run the above piece of code. And I would be grateful to you if you reply back on this thread(if this suggestion helped).

answered Jun 20, 2018 by walter 123
• 240 points

Related Questions In Selenium

0 votes
1 answer

Not able to use “explicit wait” in my code

To wait until the entire data has ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
60 views
+2 votes
1 answer

Not able to run in chrome

There is a very silly mistake in ...READ MORE

answered May 15, 2018 in Selenium by king_kenny
• 3,590 points
306 views
0 votes
1 answer

Not able to run WebDriver test with Google Chrome.

Firefox is just default browser for tests ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,590 points
218 views
0 votes
1 answer
0 votes
1 answer

Not able to open a new URL in a new tab in Selenium

There is a bug in ChromeDriver that ...READ MORE

answered May 21, 2018 in Selenium by Meci Matt
• 9,400 points
5,752 views
0 votes
1 answer

Not able to call onclick datepicker function python selenium

To pass customized dates e.g. 2017/07/14. You have ...READ MORE

answered Jun 8, 2018 in Selenium by Samarpit
• 5,130 points
762 views
0 votes
1 answer

Not able to find web element in Span Tag

Try using class selector also. driver.findElement(By.cssSelector(".login-link")).click(); hash is used ...READ MORE

answered Jun 21, 2018 in Selenium by Samarpit
• 5,130 points
1,460 views
0 votes
1 answer
0 votes
0 answers

How to hover element when action class is not working in my Selenium framework ?

When i am writing the code to ...READ MORE

Feb 15 in Selenium by Raishul
113 views
0 votes
1 answer

i am not able to perform this method in selenium driver.get("google")

Hi Sachin, are you getting any errors ...READ MORE

answered May 15 in Selenium by Abha
• 15,300 points
24 views