Create a graph with accessible data with python

I want to create a graph with python using NetworkX library, but the thing is, i want the nodes to represent an object, more precisely (a text input, a button … etc) like in HTML tags, and the edges from node to node represent the action that i will do, for exemple (clicking a button), but the most important thing that i want to do is to be able to reference those objects by an ID or Class or Name … etc, so i can access it.
Exemple : I want to represent a login web page or app, there are 2 inputs, one for the user and the second for the password, and there is a button (Login) to click. To represent this with a graph means that there are 3 nodes, the first one is the user input, then there is an edge which represent the action that i need to do to access the second node which is the password, and finally an edge which represent the click action of the third node (Login button), the third node is a button object. To access this objects, is there a way to give them an ID ?

The necessity of this is that i want to do a test automation script in a graph format, but to be able to fill the inputs automatically i need to access them. So is there way to do this or not ?

I hope you understand my idea ^_^. Thanks in advance.

Why networkX? Why not something like d3.js?

Giving an id networkX? Yes. Remember that you can add to nodes and edges all attributes you want. One of those attributes can be an id. networkX is no more than an adjacency dictionary to represent your graph. You can create and access keys and values in that dictionary.

The other thing you can try for your problem (if I understood correctly) is a graph database.