0

I have a code

driver.findElement(By.cssSelector("#lmv-dialog-add-id-_newFundAllocation-targetAllocation-88-F03   >td.tright > a.lmv-show")).click();

88 which occurs in the code is variable. How to modify the code to the code was searched regardless of whether there will be 88, 99, 12 or any other number?

in addition. On the same naming three elements xpath :

id('lmv-dialog-add-id-_newFundAllocation-targetAllocation-88-F01')/x:td[3]/x:a
id('lmv-dialog-add-id-_newFundAllocation-targetAllocation-88-F02')/x:td[3]/x:a
id('lmv-dialog-add-id-_newFundAllocation-targetAllocation-88-F03')/x:td[3]/x:a

I want to click on the third item. For this 88 is variable and I would like to do this can be for any numerical value that appears in this place.

grandecalvo
  • 213
  • 1
  • 3
  • 10

2 Answers2

0

You can try combination of XPath starts-with() and ends-with() functions :

//*[
     starts-with(@id, 'lmv-dialog-add-id-_newFundAllocation-targetAllocation-') 
        and 
     ends-with(@id, '-F11')
   ]
/td[contains(@class, 'tright']
/a[contains(@class, 'lmv-show']

Side note : Above sample shows simplified version of emulating css class selector in XPath. You can use more proper ways proposed in one of the following links, if necessary.

Community
  • 1
  • 1
har07
  • 88,338
  • 12
  • 84
  • 137
  • Unfortunately, neither this nor any other way does not want dzaiałać. Variable 88 is held by all sessions can so manage to pull it out of xpath / css? How? – grandecalvo Sep 11 '14 at 12:32
  • thanks for the links. Helped me. I used another recording using xpath contains. Once again thank you all for your help. – grandecalvo Sep 12 '14 at 13:47
0

Try with below xpath

"//*[contains(@id,'lmv-dialog-add-id-_newFundAllocation-targetAllocation')]/td[3]/a[@class='lmv-show']"
Santoshsarma
  • 5,627
  • 1
  • 24
  • 39