I am trying to automate webpages with selenium(java).
I am working on an automation tool with which an WebElement can be spied and saved. These saved webobjects can be used to perform certain actions later.
When spying an WebElement, I will get (x,y) coordinates with which I execute the following script that returns a WebElement:
webObject = (WebElement) driver.executeScript(String.format("return document.elementFromPoint(%s, %s);",new Object[] { x, y }), new Object[0]);
If (x,y) lies on a different frame, this script returns WebElement of that Frame which can be used for switching the driver. I keep on executing the same script until I get the WebElement which is not a Frame. While saving this, I save xPath which is relative to the current Frame and ID's of the Frames that I have switched so far.
Later, when performing some actions I locate the WebElement based on ID's of the Frames and xPath.
So is there a convention/standard followed by the developers to always create ID attribute for frame/iframe? If this is not true what other attributes I can rely on?