Reputation: 872
I need to test whether the external links are active and reachable by clicking the elements on the webpage. Below is an example, where we need to click on a link to navigate to panynj.gov. The problem is:
Since the newly opened URL does not match the original href value, my script is unable to select the newly opened tab.
I am looking for a solution that can either:
My codes are as follows:
*** Test Cases ***
Test for Selecting Tab using partial URL
go to ${HomePage}
Click Element xpath://*[@href="http://www.panynj.gov/"]
Test Navigation to unsecured url http://www.panynj.gov/ ${HomepageTitle}
*** Keywords ***
Test Navigation to unsecured url
[Arguments] ${href} ${Title_}
${str} = Replace String ${href} http https
select window url:${str}
${location} get location
run keyword if "${Location}"=="${str}" close window
select window ${Title_}
Upvotes: 1
Views: 510
Reputation: 872
Following the answer in How to navigate to new browser window using partial title text using either Python, or JavaScript or Robot Framework and Selenium by A Kootstra I was successfully able to resolve my problem and navigate using partial URL text.
Upvotes: 1