Finding an item in a table - Selenium scripts



  • I need to select/click an item from the table. I'm new/beginner to selenium. when I inspect the individual property, it has:

    <a id = "rpn" style=”cursor: pointer”, ng-click=”grid.appScope.viewEvent(row.event, $event)” ng-show=”row.entity.organization !== ‘Restricted’ “class=”ng-binding ng-scope” aria-hidden=”false”>123456</a> == $0
    <span ng-show=”row.entity.organization === ‘Restricted’” class=”ng-binding ng-scope ng-hide” aria-hidden=”true”>123456</span>
    

    123456 is number and link will open a page. When I’ve tried to find the CSS Selector – Got “#rpn” , When I’ve tried to find the xpath – got //*\@id=”rpn”] - I could not use xpath because of quotes around rpn. All the links in a table have the same XPath, CSS selector, link address except number. And, it is a random number too.

    The entire table has property of:

    <div role ="rowgroup" class="ui-grid-viewport ng-isolate-scope" ng-style="container.getViewportStyle()" ui-grid-viewport style="overflow:hidden;"> == $0 
    

    I need to click that first number and move on to the next testing. Not sure how to identify the property and select it. If you need any info please let me know. Any help would be great.



  • I don't see all html So I'm guessing that you can try:

    1/ id: WebElement elementName = driver.findElement(By.Id("rpn"));

    2/ Xpath:

    • //a[text()='123456']

    • OR //a[@id='rpn' AND text()='123456']



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2