1

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>
har07
  • 88,338
  • 12
  • 84
  • 137
AleMaxX
  • 69
  • 2
  • 8

4 Answers4

3

You can see the below examples

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

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

Raghuveer
  • 115
  • 2
  • 10
0

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']
Richard
  • 8,961
  • 3
  • 38
  • 47
0

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)
      ]
Community
  • 1
  • 1
har07
  • 88,338
  • 12
  • 84
  • 137
0

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

AleMaxX
  • 69
  • 2
  • 8