-1

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");
driver.sleep(5000);
module.exports.scrollto(0,400);          
driver.isElementPresent(webdriver.By.xpath(fexpath)).then(function(present){
    if (present){
        //goes logic here
    }else{
        //everytime its going here                
    }

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

QAMember
  • 1,520
  • 14
  • 37
  • 57
  • 2
    Please provide the full code and the HTML. – FDM Mar 04 '15 at 07: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 Mar 04 '15 at 23:56

3 Answers3

0

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);
Lucas Schwarz
  • 994
  • 6
  • 18
QAMember
  • 1,520
  • 14
  • 37
  • 57
-1

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).
SkorpEN
  • 145
  • 10
  • 2
    -1 because: grammar, composition, sense. Please try and correct your answer and clarify what you mean by it. – Hannibal Mar 04 '15 at 10:07
-1

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