-1

I am using selenium for flash test. I want to get id of an embed tag. I used firepath to get xapth and it looks like html/body/div[1]/div[6]/div/embed

And when I am trying to retrieve it like

browser.getAttribute(("xpath=//[html/body/div[1]/div[6]/div/embed]"));

then I am getting com.thoughtworks.selenium.SeleniumException: ERROR: Invalid xpath [2]: //*[html/body/div[2]/div[6]/object/embedd

I am using selenium 2 RC. Please anybody help to get the id attribute inside embed tag.

Prasad
  • 472
  • 5
  • 15
Ravz1234
  • 129
  • 1
  • 2
  • 12
  • 1
    very good link for using xpaths: http://test-able.blogspot.ie/2016/04/xpath-selectors-cheat-sheet.html –  May 30 '17 at 14:33

1 Answers1

4

It looks to me like you're using getAttribute incorrectly. Selenium's getAttribute method takes an attributeLocator as its parameter. The attribute locator, as the docs describe, is an element locator (in this case, your xpath) followed by "@" and the name of the attribute (in this case, id).

Try

String xpath = "xpath=//[html/body/div[1]/div[6]/div/embed]";
browser.getAttribute(xpath+"@id");

Also double-check your code. You say in your code you wrote div[1] but the error says div[2] - it's possible you just made a typo. That would explain the xpath error, although you still need to correct your use of getAttribute as well.

Selenium getAttribute docs.

larissa
  • 493
  • 4
  • 16