-1

How to locate the following element:

<a data-item-id="com.pyxis.greenhopper.jira:agile-velocity-chart" href="/jira/secure/RapidBoard.jspa?projectKey=RSWM&amp;rapidView=3254&amp;view=reporting&amp;chart=velocityChart" tabindex="-1">Velocity Chart</a>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Velocity Chart – shiva satheesh Jun 18 '19 at 14:33
  • this is the actual html code for element – shiva satheesh Jun 18 '19 at 14:34
  • 1
    Welcome to StackOverflow! Your question needs some work so the community can better help you. Take a look at [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and give it another try. – Chris Albert Jun 18 '19 at 14:36
  • It's important to have a bit more context. Ideally, when finding elements for automated testing, you want to search for something that's not likely to change. – Rick Jun 18 '19 at 14:39
  • Please specify which exact element or attribute you need to get through your xpath. Much better is also to post a full well-formed xml, not just one tag. – Dmitriy Popov Jun 18 '19 at 14:47

2 Answers2

1

You can use either of the following Locator Strategies:

  • cssSelector:

    a[href^='/jira/secure/RapidBoard'][data-item-id$='agile-velocity-chart']
    
  • xpath:

    //a[starts-with(@href, '/jira/secure/RapidBoard') and contains(@data-item-id, 'agile-velocity-chart')][text()='Velocity Chart']
    
Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
1

The only thing which looks non-dynamic and human-readable is link text so the relevant XPath expression would be:

//a[text()='Velocity Chart']

you might also want to match the element using chart=velocityChart bit, if this is the case you can look up href attribute using XPath contains() function like:

//a[contains(@href,'velocityChart')]

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133