1

I was trying to select the highlighted Xpath in this Photo below. Afterwards I was trying to click on the element.

Code trials:

On Error Resume Next
Set Element = GC.FindElementByXPath("//*a[@data-id='_VIEW--ALL_COMPLAINTS_VIEW_P']")
Set Element1 = GC.FindElementByXPath("//*/div/a[contains(@data-id,'_VIEW--ALL_COMPLAINTS_VIEW_P')]]")
test = Element1.Value
Element.Click
Element1.Click
Set Element3 = GC.FindElementByCss("a[data-id='_VIEW--OPEN_BY_CODE_P']")
Element3.Click
GC.FindElementById("_VIEW--OPEN_BY_CODE_P").Click

But on both tryouts I wasn't able to do it. First Element is Empty second Element not.

The element is at the bottom and is the blue highlighted line.

enter image description here

PS: I hoped there is some unknown thing like an Iframe which you can solve by switch to. Perhaps this "<!--->".

HTML Snapshot:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
protter
  • 119
  • 7
  • 1
    Did you try `Set Element = GC.FindElementByXPath("//*/a[@data-id='_VIEW--ALL_COMPLAINTS_VIEW_P']")`? Note the `/` after `*`. – z32a7ul Jun 09 '23 at 12:28
  • Yes now, but this Element is also empty. – protter Jun 13 '23 at 06:24
  • `GC.FindElementByXPath("//*/*[contains(@text, 'All Complaints by Number')]") ` For what i can see, there probably is an empty element with the exact same locator as is currently used. Check if this approach works. This way it would only start with the non-empty element. – Knight Jun 30 '23 at 11:43

1 Answers1

1

You were close enough. Given the snapshot of the HTML there is no iframe. The element:

VIEW--OPEN_BY_CODE_P

is within an <a> tag with data-id attribute as _VIEW--ALL_COMPLAINTS_VIEW_P and text as All Complaints by Number


Solution

To locate the element you can use either of the following locator strategies:

  • Using FindElementByCss:

    Set Element = GC.FindElementByCss("a[data-id='_VIEW--ALL_COMPLAINTS_VIEW_P']")
    
  • Using FindElementByXPath and data-id attribute:

    Set Element = GC.FindElementByXPath("//a[@data-id='_VIEW--ALL_COMPLAINTS_VIEW_P']")
    
  • Using FindElementByXPath and the text All Complaints by Number:

    Set Element = GC.FindElementByXPath("//a[text()='All Complaints by Number']")
    
  • Using FindElementByXPath data-id attribute and the text All Complaints by Number:

    Set Element = GC.FindElementByXPath("//a[@data-id='_VIEW--ALL_COMPLAINTS_VIEW_P' and text()='All Complaints by Number']")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352