1

Html of the element:

<div _ngcontent-nxg-c15="" class="box-shadow"><!----><a _ngcontent-nxg-c15="" class="clearfix con-card-voucher text-center ng-star-inserted" style="background-image: url(&quot;https://api.duniagames.co.id/api/product/upload/image/9231439531578882989.jpg&quot;);" href="/top-up/item/freefire"><!----><img _ngcontent-nxg-c15="" alt="Item Logo" class="icon-image style2" onerror="this.onerror=null;this.src='./assets/images/primary-logo.jpg';" src="https://api.duniagames.co.id/api/product/upload/image/13838880871566571420.jpg"><div _ngcontent-nxg-c15="" class="right style2"><h5 _ngcontent-nxg-c15="" class="title"><b _ngcontent-nxg-c15="">FreeFire</b></h5></div></a><!----></div>

The coding I used before was like this, but failed

Driver.FindElement(By.LinkText("FreeFire")).Click()

how to code properly I use VB.Net

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

1

The desired element is an Angular element you need to induce some wait and you can use either of the following Locator Strategies:

  • Using FindElementByCss:

    Driver.wait 3000 
    Driver.FindElementByCss("div.box-shadow a[href='/top-up/item/freefire'] h5.title>b").Click
    
  • Using FindElementByXPath:

    Driver.wait 3000 
    Driver.FindElementByXPath("//h5[@class='title']/b[text()='FreeFire']").Click
    

Reference

You can find a relevant discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352