1

I am attempting web automation with a platform called Robocorp using the Selenium library.

When I run my program, I have no issues until I encounter this page where I am trying to get the program to click on the icon that says SQL.

I want the <a> element with the @href attribute.

Here are some (of many) XPaths I have tried that have all failed:

  • xpath://a[contains(@href,'sql_form.jsp')]
  • xpath://*[text()='SQL']
  • xpath://a[@target='frame2]

Snapshot of the element:

UI element

I circled the element in red ^^^

I cannot get the selector to be recognized on this page. I have tried adding delays, waiting until the element is active, waiting until the element is visible, etc.

Nothing seems to work.

Element data from 'inspect'

Here is an image of the elements I am trying to select. (The link in the href element takes me to the page I am trying to access).

I thought that the third one would for sure work but is still failing.

I am using a platform called Robocorp which only needs the raw selector to work (CSS or XPath)

VS Code - Robocorp program

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
David
  • 45
  • 5

2 Answers2

2

I was unaware that iframe needed to be handled differently or that it even existed https://robocorp.com/docs/development-guide/browser/how-to-work-with-iframes

I first needed to switch frames.

David
  • 45
  • 5
1

To identify the element with text as SQL you can use you can use either of the following locator strategies:

  • Using Wait Until Element Is Visible:

    Wait Until Element Is Visible    xpath=//a[starts-with(@href, 'sql_form.jsp') and @target='frame2']/font[text()='SQL']    10  seconds
    
  • Using Wait Until Element Is Enabled:

    Wait Until Element Is Enabled    xpath=//a[starts-with(@href, 'sql_form.jsp') and @target='frame2']/font[text()='SQL']    10  seconds
    

References

You can find a couple of relevant detailed discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Thanks for the useful information, however, I am still getting an error saying the selector cannot be found: Element with locator 'xpath=//a[starts-with(@href, 'sql_form.jsp') and @target='frame2']/font[text()='SQL']' not found. – David Feb 13 '23 at 19:47