Question

How to write Contains or Starts-with for the following dinamyc revit id?

id=revit_form_Button_55_label

or

xpath attribute as following:

//span[@id='revit_form_Button_55_label']

<span id="revit_form_Button_67_label" class="dijitButtonText" dojoattachpoint="containerNode">Yes</span>
Was it helpful?

Solution

You can see the below examples

1) "//a[contains(.,'continue')]"

2)"//div[starts-with(@class,'bdyItmPrt')and contains(.,'Registration Information Entered by User:')]"

OTHER TIPS

You could use starts-with() plus ends-with() function :

//span[starts-with(@id, 'revit_form_Button_') and ends-with(@id, '_label']

Or if ends-with() is not available in your platform, you can replace it with snippet by @DimitreNovatchev :

substring($str1, string-length($str1)- string-length($str2) +1)

So the entire XPath would be like :

//span[
        starts-with(@id, 'revit_form_Button_') 
            and 
        substring(@id, string-length(@id)- string-length('_label') +1)
      ]

I think this will work for you:

//span[starts-with(@id, 'revit_')]

This adds class to the selector:

//span[starts-with(@id, 'revit_')][@class='dijitButtonText']

Here is what worked: //span[starts-with(@id, 'revit_form_Button_') and contains(.,'Yes')][@class='dijitButtonText']

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top