Expose specific component details in HTML

I currently have a relatively simple python script using selenium to open and do some general interactions with a Perspective project, that I can run in a swarm of docker containers and simulate a bit of load on a gateway.

This is pretty easy to do, however the way its done is kind of “non-deterministic” in approach. To find the specific component you want in selenium I have to access them by their IA class names, for example I may use the following function to click on a random row in a table:

def clickOnTableItem():
    # Wait for the table to load its contents
    while len(driver.find_elements_by_class_name("ia_table__body__rowGroup")) < 1:
    # Get count of items in the table
    tableRows = driver.find_elements_by_class_name("ia_table__body__rowGroup")
    # Define a random index from count
    selectedIndex = random.randint(0, len(tableRows))
    #Find the table row by its index
    row = tableRows[selectedIndex]
    # Click on element

While this is fine if there is one table that takes up my page, what do I do if I have two tables? I would think that I might look for any rows inside of table 1, and then click on one, but I could have a dynamic number of tables (or similar component) but if it was possible to expose specific perspective properties in the HTML, I could find those and identify the container to search in.

In example, if I had 5 buttons on the screen, and each buttons name showed up as a class for that element. I could use find_elements_by_class_name("MyButtonName") to identify the element and click on it.

One thing I have thought about is applying a fake style class to a component and then referencing that component with the perspective style class like find_elements_by_class_name("psc-FakeStyles/MyButtonName") but this doesn’t feel like the cleanest solution.

Any ideas would be greatly appreciated!

This is the answer to that question for anyone that sees this when they look up the same issue:

1 Like