1

So I am trying to get a script to work that will obtain the current URL of the open tab, replace a portion of the URL, and enter in/navigate to the new URL which has the replaced text.

I'm struggling with the replace function as well as how to launch the edited URL in the current tab.

Here a rough idea of how I think it should look. If this worked worked it would open up a new browser with the new URL but I'd like it to be on the tab I'm currently in.

Would I need to crate an object for the result of the replace function?

If I were currently at

abc123.UZ.com/xaxsxa

I'd like to go to the page

xyz789.UZ.com/xaxsxa

Code:

 Browser("Edge").Page("Loan#").WebButton("LoanConditions").Click
 Browser("Edge").Page("Loan#).GetROProperty("url") 
 Result = Browser("Edge").Page("Loan#").GetROProperty("url")
 replace (Result,"abc123","xyz789")
 Systemutil.Run "Chrome.exe", "Result"
bad_coder
  • 11,289
  • 20
  • 44
  • 72

1 Answers1

2

Use the Navigate method of the Browser object.

You just need to replace the last 2 lines with:

Result = replace(Result,"abc123","xyz789")
Browser("Edge").Navigate Result

Update(Based on the issue mentioned in Comments):

Try this code. This is still untested by me. So, let me know if it works for you.

set odesc = Description.create
odesc("micclass").value = "Browser"
intBefore = Desktop.Childobjects(odesc).count
Browser("Edge").Page("Loan#").WebButton("LoanConditions").Click
Browser("Edge").Page("Loan#").Sync
intAfter = Desktop.Childobjects(odesc).count
if intAfter = intBefore + 1 then
    intIndex = intAfter-1
    set objBro = Desktop.Childobjects(odesc).item(intIndex)
    Result = objBro.getRoProperty("url")
    Result = replace(Result,"abc123","xyz789")
    objBro.Navigate Result
end if
Gurmanjot Singh
  • 10,224
  • 2
  • 19
  • 43
  • Hi Gurman, this seems to be working however I ran into an issue. the.click in the above code is opening up a new tab and this code seems to be looking at the URL in the current tab and not the the one that is opened with the click. How do you make the newly opened tab active so that it will change the URL there and not the URL where the click was performed? – Zachary Pichette Jan 03 '18 at 16:54
  • @ZacharyPichette Can you run [THIS](https://codeshare.io/5wq1oD) code and let me know what values you see in the message boxes? – Gurmanjot Singh Jan 03 '18 at 18:34
  • The test run cannot continue due to a syntax error. Expected identifier Line (32): "Desktop.Childobjects(odesc).item(intIndex).". – Zachary Pichette Jan 03 '18 at 19:02
  • So with this it gets the URL from the second tab and enters it in the first tab. Really appreciate all your help on this! – Zachary Pichette Jan 03 '18 at 19:14
  • I was hoping that it would enter the updated url in the 2nd tab itself. Not sure what happened there. Anyways, glad it worked for you. If I come across a simpler solution, I will update this answer. – Gurmanjot Singh Jan 03 '18 at 19:16
  • Was able to get this to work using Browser("CreationTime:=1").Navigate Result in place of objBro.Navigate – Zachary Pichette Jan 03 '18 at 22:22
  • That thing did come to my mind but I didn't want to hardcode the browser creation time as it will fail incase there is another instance of browser already running. – Gurmanjot Singh Jan 04 '18 at 01:04