Can i increase the value of selectors

I have a scenario in which i send the questions through excel one by one and get answers from bot automatically.
I have more than 200 questions and get answers by bot.
In the answer panel selectors changes with every answers it increase its value by one .
Can there is any way to increase the particular value in selectors.

div[id=“content”] > div[class=“bot_msg_wrapper”]:eq(1) > div[class=“msg_container bot second_msg”] > div[class=“msg_wrp”] > div[class=“msg animated bounceIn”] > p

div[id=“content”] > div[class=“bot_msg_wrapper”]:eq(2) > div[class=“msg_container bot second_msg”] > div[class=“msg_wrp”] > div[class=“msg animated bounceIn”] > p

div[id=“content”] > div[class=“bot_msg_wrapper”]:eq(3) > div[class=“msg_container bot second_msg”] > div[class=“msg_wrp”] > div[class=“msg animated bounceIn”] > p

I fetch the value by ‘innertext’ only eq value increases by 1
how can i handle it.

1 Like

@nutan y
you can do it by using module:
WebAutomation.ExecuteJavascript BrowserInstance: Javascript:‘function ExecuteScript() { /*your code here, return something (optionally); */ }’ Result=> Result

Note you can use this module in loop and same loop value you can pass it in queryselector

2 Likes

@nutan another approach would be to make use of the text representation of the Control and pass the index as a variable inside the loop.

So the result would be something like this:

loop foreach Index in ListOfIndices
    WebAutomation.FormFilling.PressButton BrowserInstance: \
    Browser Control: '''domcontainer{<{<{<SelectorSeparator>}>}>}uia3:// 
    div[id=“content”] > div[class=“bot_msg_wrapper”]:eq('''+Index+''') 
    > div[class="msg_container bot second_msg"] 
    > div[class="msg_wrp"] > div[class="msg animated bounceIn"] > p'''
 end
2 Likes

@nutan yes you can make the custom selector dynamic and then insert a value during the execution of the script.

For example I have retrieved this selector from a page:
li[id=“p_89/< Brand>”] > span[class=“a-list-item”] > a[class=“a-link-normal s-navigation-item”] > div[class=“a-checkbox a-checkbox-fancy s-navigation-checkbox aok-float-left”] > label > input[type=“checkbox”]

notice the bold <> including a variable name (in this case “Brand”).

After that you can pass values to this variable through your Robin script.

WebAutomation.FormFilling.SetCheckboxState BrowserInstance:amazonInst
Control: Amazon.SearchPage.input_checkbox(Brand: “ASUS”)

As shown above you can do it by including inside parenthesis the name of the variable you have created in the selector and assigning it a value.

Regarding your scenario, you could do this by creating a loop from 1 to 200, increase a counter by 1 in each step and pass the value of the counter the way I demonstrated.

Hope it helps.

Best regards,
J.

3 Likes