0
votes

I am getting below error while trying to automate sample Qlikview web report though Selenium

Browser: Firefox

Xpath returned by FirePath:

  .//*[@id='58']/div[2]/div/div[1]/div[4]/div[1]

Exception:

  **Exception**: Exception in thread "main"                 
   org.openqa.selenium.InvalidSelectorException: The given    
   selector//[@id='58']/div[2]/div/div[1]/div[4]/div[1] is either invalid          
   or does not result in a WebElement. The following error occurred:      
   InvalidSelectorError: Unable to locate an element with the xpath       
   expression //[@id='58']/div[2]/div/div[1]/div[4]/div[1] because of the     
   following error:**SyntaxError: The expression is not a legal expression.**
   Command duration or timeout: 78 milliseconds
   For documentation on this error, please visit: http://seleniumhq.org       
   /exceptions/invalid_selector_exception.html
    Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'

I tried running by removing '.' from xpath but still the same error is occuring.

Code Sample:

// Navigate to Quarter 4 Results

    driver.findElement(By.xpath("//[@id='58']/div[2]/div/div[1]/div[4]/div[1]")).click();
}

Application: http://us-b.demo.qlik.com/QvAJAXZfc/opendoc.htm?document=qvdocs%2FRetail%20Omni-Channel%20Analytics.qvw&host=demo11&anonymous=true

I am trying to click Q4 link on this application

Please help.

1

1 Answers

1
votes

You have to give tag name in your xpath. You didn't mention any tag name. You can give * that can take any tag.

 //*[@id='58']

The above will match any element that has id=58

You have used

 //[@id='58']

in which the tag name is missing.So it's an invalid selector.You have to mention * or proper tagName of the element like div or something

use below line:

driver.findElement(By.xpath("//*[@id='58']/div[2]/div/div[1]/div[4]/div[1]")).click();

instead of:

 driver.findElement(By.xpath("//[@id='58']/div[2]/div/div[1]/div[4]/div[1]")).click();