I have requirement that needs to check a div on home page that contains sub images. I am trying like this

My Sample Code :

module.exports.openurl('www.google.com', "Online Shopping | Buy Phones, Computers,Fashion");
    if (present){
        //goes logic here
        //everytime its going here                

Here I am getting false as return value. I'm not sure what I'm doing wrong.

  • 2
    Please provide the full code and the HTML.
    – FDM
    Commented Mar 4, 2015 at 7:45
  • are you sure fexpath exists? Are you really saying that if you comment out the module.exports.scrollto(0,400);, it works? That sounds dubious to me . . .
    – ernie
    Commented Mar 4, 2015 at 23:56

3 Answers 3


Thanks for your suggestions Guys

I have solved my problem by using the javascript executor. Below is the code:

var element = driver.findElement(webdriver.By.xpath(xpath));
driver.executeScript("arguments[0].scrollIntoView(true);", element);

U should try scroll to element. it is in api. Element should be visible to interact with it.

also check:

  1. Did it occurs when windows is maximized?
  2. Did it work with css locator?
  3. Is it browser dependent?(on all drivers or specific one).
  • 2
    -1 because: grammar, composition, sense. Please try and correct your answer and clarify what you mean by it.
    – Hannibal
    Commented Mar 4, 2015 at 10:07

Best practices recommend to use XPath as locator of last resort. Did you tried locating element by ID or name? Or even CSS?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.