I'm quite new to Python and Selenium and I need help with a few things. I searched and experimented for a few days now but I'm stuck with no ideas what so ever.
Here is what I am trying to do:
I have a table with a bunch of orders. And in there, each sell I've made has a sales record with the buyer's information.
Inside the page with all the sales there is a table that looks as follows :
Once you click on the little devil's arrow you get the following menu:
All I need is a way to click on the " View sales record " option from each arrow on every sale on the page, and to open each sales record in a different tab. ( Every day the number of sales varies )
I tried over 20 different ways to open the sales record link but so far the only thing that seems to work is the following code:
driver.execute_script("document.querySelector('#LineActions > div > div > div.mu-ov-w.mu-d-ov > div > div.mu-ov-c1 > div > div > table > tbody > tr > td > ul > li:nth-child(3) > a').click();")
When the browser loads the page and the script executes it opens the sales record for the first order. The problem is that I have no idea how execute the script for every other order.
Every arrow and link is placed inside a tbody tag. The table looks like this:
<table id="tbl_mu_active_tbl_id"....>
<thead class="dt-cs" id="tbl_mu_active_tbl_id_h_0">
....
<tbody class="dt-rs dt-cs">
<tr class="dt-sh dt-slb dt-fr" id="mu_active_tbl_id_0">
....
<tbody class="dt-nsb">
....
<tbody class="dt-rs dt-cs">
<tr class="dt-sh dt-slb dt-fr" id="mu_active_tbl_id_1">
....
The tag with 'class="dt-nsb"' is the empty space between each line with 'Sell similar' ( as seen in the first picture )
The id always adds one to the id of the previous relevant tag.
The selector for the first row is #tbl_mu_active_tbl_id > tbody:nth-child(2)
For the second one: #tbl_mu_active_tbl_id > tbody:nth-child(4)
And so on.
I tried a number of ways for iterating through table rows but I couldn't get the script to execute on none of the other rows.
To sum up, the present questions are:
How to execute the script on each row of the table?
Is there a way to make the script to open the link in a new tab ?