xPath is not working in case of multiple select box

rpa
rpaexpress

#1

Xpath is not working in case of select box

It opens in popup, and select multiple options and add to next section.

I am using like id(‘lstCodes’)/x:option[8] or /html/body/form/div[3]/table/tbody/tr[4]/td[1]/select/option[8]

Both type of xpath not working.

Please suggest, it’s urgent.

Thanks
Ajay


#2

@Ajay_Singh_Rawat6

Hi Ajay,
please post your zipped recording here (or a part of recording with the actions in question).

Alesia


#3

@ashapkina

Hi Alesia

I can’t send a recorded zip file, as it is some confidential data.

Please suggest another way to do.

Thanks
Ajay


#4

@ashapkina

Right now it is approximately 300 steps with loops.

Thanks
Ajay


#5

@Ajay_Singh_Rawat6
then please provide the page URL and a detailed description of what actions you need to perform there.


#6

@ashapkina

Actually, the URL contains login/password.

If you have any other option, please suggest.

Thanks
Ajay


#7

@Ajay_Singh_Rawat6
In this case, copy the html code of the page where you need to use the xpath to a file and send it to us. You can delete the sensitive information if it contains any.


#8

@ashapkina

Hi Alesia

I want to match with dynamic code depends on each ID and select option mentioned below are:

To match and get the value of option, I used xpath:

id(‘lstCodes’)/x:option[8]
OR
/html/body/form/div[3]/table/tbody/tr[4]/td[1]/select/option[8]

PFA for html source code.

html_source_code.txt (9.0 KB)

Ajay


#9

@ashapkina

Hi Alesia

Had a chance to check this issue?

Thanks
Ajay


#10

Hello, @Ajay_Singh_Rawat6

Did you try to use native selenium wrapper over select elements?
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html

In this case you can define your select element as

import org.openqa.selenium.support.ui.Select; 

Select selectElement = new Select(By.id("lstCodes"));

and then use class API to work with values. In your case if I understood your question correctly, you can select by index or value or visible text:

selectElement.selectByValue("D001");
selectElement.selectByIndex(0);
selectElement.selectByVisibleText("D001: IGNITABLE WASTE");

#11

@roman_kelemen

Hi Roman

Where and how can i use this?

Thanks
Ajay


#12

Hi

If you are working with Recorder, then you may export your final flow to groovy script / bot task and make changes directly in bot configuration script. Unfortunately, Recorder doesn’t support custom actions yet so you’ll have to do some coding.

To debug exported code, use SPA Studio. In order to run - import configuration to control tower and use it in your business process.


#13

Yes actually I am using RPAe tool not SPA.

Thanks
Ajay


#14

@Ajay_Singh_Rawat6
Hi Ajay, use xPath //*[@id=“lstCodes”]/option[8]


#15

@ashapkina

Hi Alesia

Just checked !!

Here is the screenshot:

Capture

Not worked on select option get value using web element or mouse click event. It is opened in popup browser.

Thanks
Ajay


#16

@Ajay_Singh_Rawat6 What browser did you use?


#17

@ashapkina Chrome, as Mozilla and IE not working


#18