I have written two posts recently regarding Selenium Factory. The idea of Selenium Factory being to log all web elements a user interacts with on a website, as well as filling out forms via typing, etc. I recommend reading those two articles first:
In this article, I will explain how to track and store user selected web elements by sending the selected web elements back to the Qt application and store them for later in-order retrieval. This was rather difficult and there was very little clear documentation, I completed this article with the help of Gaurav D. Kale and hope it can help others who need similar functionality.
Q_INVOKABLE void webElement(QString);
That is it, every time a user clicks on a web element the characteristics (id, name, and class) are sent to the Qt function webElement to do with what we will.
Storing the Web Elements
Once we have the web elements the rest is relatively easy. What I did to accomplish this is build a class called generate, which is a bit of overkill for the current job, but I will be using in the future making it worth while.
The class is defined below:
I can then initialize the variable userActionList in the constructor and add web elements the user selected by defining the webElement(QString) function:
Then by calling:
We will receive an in-order list of all web elements selected by the user, easy-peasy. For example, if I clicked:
My output would be:
In the exact order each click was made.
For the next article in this series, I plan to write about intercepting user input and storing it with associated form input.
I will post a link here for the next article in the series as well as send an update on my mailing list so feel free to sign up (fill out form below)!