Miko
Miko

Reputation: 129

Selenium find xpath of select node

I am trying to generate the xpath for the following:

    <select data-bind="options: PrinterLabelTypes, optionsValue: 'value', optionsText: 
    'value', value: NewPrinterLabelTypeText, optionsCaption: GetText('SelectLabelType')">. 
     <option value="">Choose Printer Label Type...</option><option 
    value="Batch">Batch</option><option value="Despatch">Despatch</option>
    </select>

I have tried the following:

    //select[@data-bind='value: NewPrinterLabelTypeText']

But i am not getting anything back. Have i missed something. Is there a way to do it using the format above?

Upvotes: 0

Views: 64

Answers (1)

supputuri
supputuri

Reputation: 14135

You have to use contains when your locator is using part of the attribute value.

//select[contains(@data-bind,'value: NewPrinterLabelTypeText')] 

Upvotes: 1

Related Questions