This is my custom view where \"LondonStreet\"
is a button.
When I tap that button I get url and open it in Safari (it works). Then I can go back, u
UI Testing cannot interact with anything outside of your application. In your scenario, the framework can no longer do anything once your app opens Safari.
To verify this, try printing out the app's hierarchy once Safari opens. You will notice that nothing in Safari nor the navigation bar will show up - you will only see your app's information.
print(XCUIApplication().debugDescription)