Why aren't custom tags supported yet in Selenium WebDriver? I realise the W3C web components proposal is still under review, but browsers are already implementing them widely (angular apps come to mind e.g. ng-app).

  • 1
    Can you please give example of custom element? Commented Dec 7, 2015 at 3:47
  • 1
    We use Angular, and I ask developers to add names or IDs to relevant generated elements 9or do it myself). Selenium webdriver has no problem finding them, so not sure what is your problem. Commented Dec 7, 2015 at 14:59
  • @HelpingHands html5rocks.com/en/tutorials/webcomponents/customelements
    – raven
    Commented Dec 8, 2015 at 4:54
  • @PeterMasiar I don't have control or influence over the codebase
    – raven
    Commented Dec 8, 2015 at 4:56
  • Re: "but what if the elements aren't known?". Can you give an example?
    – dzieciou
    Commented Dec 8, 2015 at 13:37

1 Answer 1


You can find custom elements by using the tagName;

Example of how to find an element that looks like this:

<iframe src="..."></iframe>

would be

WebElement frame = driver.findElement(By.tagName("iframe"));

Full documentation is available on the Selenium API

I would also suggest you maintain a separate list (or Enum) of your custom elements as they are dynamically generated so easily changed in the code base which could lead to a high number of tests needing updating.

  • 1
    Thanks but that still doesn't answer why it's not included in the spec. This is a workaround.
    – raven
    Commented Dec 8, 2015 at 19:32
  • This example is the official way of finding an element by tag name (custom or otherwise). I am not quite sure what you mean by it not being in the spec.
    – ECiurleo
    Commented Dec 9, 2015 at 9:50
  • Fair enough, accept that may have not come across clearly. Here's a simple scenario. Navigate to the custom elements example, open a console and type in document.body.getElementsByTagName("*").length - you should get 6 returned as the result. Using webdriver, I try (def d (execute-script "var n = document.body.getElementsByTagName(\"*\"); return n;")) and a count on that returns 5. Why is webdriver filtering my results?
    – raven
    Commented Dec 11, 2015 at 5:26
  • I see what you mean. I would suggest you post that as a separate question as I am sure someone will know the answer (I don't at this point). My only thought is n being defined as a base 0 value
    – ECiurleo
    Commented Dec 11, 2015 at 9:22
  • 1
    Done sqa.stackexchange.com/questions/16091/…
    – raven
    Commented Dec 13, 2015 at 0:00

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.