RE: Unable to locate an element

hi  –

I am unable to locate an element on a travel website. I tried locating through absolute/relative xpaths, id and class but its not working.

<div id=”divBanner class=”all_page>
<input id=”hPopularCity type=”hidden>
<input id=”hTodaysPredefined type=”hidden>
<script type=”text/javascript src=”/Content/js/common/jquery-ui.js>
<script type=”text/javascript src=”/Content/js/FlightDatePicker.js>
<link type=”text/css rel=”stylesheet href=”/Content/css/jquery-ui.css>
<link href=”/Content/images/favicon.ico type=”image/x-icon rel=”shortcut icon>
<script type=”text/javascript>
<section class=”center>
<input id=”showCountdown type=”hidden value=”true>
<div class=”bottom_content>
<div class=”wrapper>
<div class=”container>
<section class=”itinarary_content>
<div class=”itinarary_left>
<div class=”itinarary_left_top>
<div class=”bredcrumb mt_20>
<div class=”flight_itinara_area mt_15>
<div class=”flight_itinara_area>
<div class=”itinarary_tottal_area mt_20>
<div class=”itinarary_tottal_right>
<input id=”ItCurrency2 type=”hidden value=”KWD>
<div class=”itinanary_book_now>
<a href=”/en/Flight/PaxDetails?TripId=0>Book Now</a>

I am pasting the HTML code for reference and I wanted to click on the link “Book Now”.
<a href=”/en/Flight/PaxDetails?TripId=0>Book Now</a>

I tried following options
1) @FindBy(linkText=”Book Now”)
private WebElement bookNow;;

2) WebDriverWait wait = new WebDriverWait(driver, 100);
wait.until(visibilityOfElementLocated(By.linkText(“Book Now”))).click();

3) @FindBy(xpath=”//*[@id=’divBanner’]/section/div/div/div/section/div[1]/div[5]/div[1]/div/a”)
private WebElement bookNow;;

4) @FindBy(xpath=”/html/body/div[1]/div[3]/section/div/div/div/section/div[1]/div[5]/div[1]/div/a”)
private WebElement bookNow;;

Aruna Default Asked on October 30, 2014 in Selenium WebDriver.

Hi Aruna

can you please check the occurances of your Xpath on firepath?

on October 30, 2014.

Hi Aruna

If i was you, probably i would have used css which is much more concise and easy to read
@FindBy(css = “.itinanary_book_now a”)

on November 7, 2014.
Add Comment
2 Answers


Your xpaths are perfect but sometimes the ‘a’ tag does not work on buttons, try clicking on its div element:


private WebElement bookNow;;

Please send us the screen shot of the button with opened HTML below it or if there is any way we can access the webpage.

As Ankit as suggested above, have you checked the XPath on firepath, is it locating your Book Now button when you enter your xpath on Firepath.

Lakshay Sharma

Professor Answered on October 30, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.