Replacing portion of a URL in HPE UFT / VBscript - vbscript

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"

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

Related

TextBox1.Text string on end of a link

I wanted to make an application that checks if a link was blocked on steam.
I used the linkfilter page. (https://steamcommunity.com/linkfilter/?url=)
I tried doing it like this:
WebBrowser1.Url = https://steamcommunity.com/linkfilter/?url=(TextBox1.Text)
But I got two errors. Is there a way to do this?
Did you try setting your string values as actual strings?:
WebBrowser1.Url = new Uri("https://steamcommunity.com/linkfilter/?url=" + TextBox1.Text);
or:
WebBrowser1.Url = new Uri(string.Format("https://steamcommunity.com/linkfilter/?url={0}", TextBox1.Text));

CodeIgniter Pagination with number in the middle of the query string

I searched the whole day for any solution but did not found any.
I have the same problem as this guy here: Codeigniter Pagination having page number in the middle of url but the "uri_segment" param doesn't work.
My Urls look like:
localhost/controller/0/some/filter/here/
The Pagination returns teh correct link for the next and 2. page.
But once I go there, I get a wrong link back to the first site.
I did something like this:
/*Paginartion Config*/
$pagconfig['base_url'] = base_url($this->uri->segment(1).'/0/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$this->uri->segment(5).'/'.$this->uri->segment(6).'/'.$this->uri->segment(7).'/'.$this->uri->segment(8));
$pagconfig['total_rows'] = $ress->num_rows;
$pagconfig['per_page'] = 10;
$pagconfig['uri_segment'] = 2;
$pagconfig['prefix'] = '/'.$this->uri->segment(1).'/';
$pagconfig['suffix'] = '/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$this->uri->segment(5).'/'.$this->uri->segment(6).'/'.$this->uri->segment(7).'/'.$this->uri->segment(8);
Also I just tried using the current_url() as base_url config param and of course I also just tried to use uri_segment = 2 without using pre- and sufix.
It never worked properly.
Routes look like this:
$route['map/(:num)/(:any)'] = 'map/index/$1/$2';
$route['map/(:num)/(:any)/(:any)'] = 'map/index/$1/$2/$3';
$route['map/(:num)/(:any)/(:any)/(:any)'] = 'map/index/$1/$2/$3/$4';
$route['karte/(:num)/(:any)'] = 'map/index/$1/$2';
$route['karte/(:num)/(:any)/(:any)'] = 'map/index/$1/$2/$3';
$route['karte/(:num)/(:any)/(:any)/(:any)'] = 'map/index/$1/$2/$3/$4';
As you can see I use two kind of routes, translates for google.
The routes and Controller also work!
If I type in by hand I get the correct paginated site content:
For Example: localhost/controller/10/some/filter/here returns every row beginning with 11 (it skips first 10 as it should).
Very important is that the number always appears even on the first page where it is 0 - as you can see above.
It would be so great to get any help in that one...
Best Regards

Need assistance with unfamiliar syntax, error - e is undefined - Google Apps Script(GAS)

I'm using a script exactly like the one on the tutorial here, https://developers.google.com/apps-script/reference/ui/file-upload
However, despite using the syntax I keep getting e is undefined in the statement:
var fileBlob = e.parameter.dsrFile;
I think that means my function doPost(e) is probably wrong somehow. Here is my entire script below.
// Create Menu to Locate .CSV
function doGet(e) {
var app = UiApp.createApplication().setTitle("Upload CSV");
var formContent = app.createVerticalPanel();
formContent.add(app.createFileUpload().setName("dsrFile"));
formContent.add(app.createSubmitButton("Start Upload"));
var form = app.createFormPanel();
form.add(formContent);
app.add(form);
return app;
}
// Upload .CSV file
function doPost(e)
{
// data returned is a blob for FileUpload widget
var fileBlob = e.parameter.dsrFile;
var doc = DocsList.createFile(fileBlob);
}
e is undefined because you are not passing anything to doPost. You have to pass the needed object to doPost. Check where you call the function and what parameters do you pass to it if any. Even if you pass a parameter to that function, it holds undefined value. Make sure that you are passing the correct objects to your functions.
Your script should work perfectly. e is defined by Google Apps Script, not need to pass anything in particular is contains the fields of your form, in particular in this case the file you uploaded.
I would suspect you may be falling foul to the dev url vs publish url syndrome, where you are executing an old scrip rather that the code you are currently working on.
Be sure you script end with 'dev' and not 'exec'
https://script.google.com/a/macros/appsscripttesting.com/s/AKfyck...EY7qzA7m6hFCnyKqg/dev
Let me know if you are still getting the error after running it from the /dev url

ArcPad - VBscript - Autopopulate attributes

I am using the following script to grab parcel and address information from one layer to fill the attribute table of a newly created feature.
There is no returned error, but the problem I am having is that there seems to be the wrong information stuck in the memory of recordselect function. No matter where I place a point it gives the same parcel # and address. Or maybe it isn’t actually be performing the IF function properly.
Sub Address
Dim rsCurrentXY
Set rsCurrentXY = Map.Layers("Violations").records
rsCurrentXY.movelast
Dim objXYShape
Set objXYShape = rsCurrentXY.Fields.Shape
Dim pControls
Set pControls= Application.Map.selectionlayer.Forms("EDITFORM").Pages(“PAGE1”).Controls
Dim rsGrid
' Find corresponding map page to the valve point
Set rsGrid = Map.Layers("ACPA_parcels").records
rsGrid.movefirst
Do While Not rsGrid.eof
If rsGrid.fields.shape.Ispointin(objXYShape) Then
pControls("txtAddress").value = rsGrid.Fields("ADD1").Value
Exit Do
End If
rsGrid.Movenext
Loop
' Clean Up
Set rsCurrentXY = Nothing
Set objXYShape = Nothing
Set rsGrid = Nothing
End Sub
(I have another subroutine called "PIN" that would do the exact same thing.)
I have them called when their respective edit boxes in the custom form are activated by the inspector.
Thanks for the help,
Robert
Accessing the EDITFORM via Application.Map.selectionlayer.Forms("EDITFORM") will be problematic. Whenever working with controls on an EDITFORM you should using ThisEvent.Object to discover all your objects. For example, if your event handler is Page_OnLoad then ThisEvent.Object will refer to your current page. You should have code like this:
Dim pPage1
Set pPage1 = ThisEvent.Object
Dim pControls
Set pControls = pPage1.Controls

Windows Phone 7 WebBrowserTask problem

I'm trying to open this url using a WebBrowserTask in WP7, and it doesn't work (I get a custom error on our website), but when I type it in by hand, it works fine. Any ideas?
It also works perfectly fine in Google Chrome and IE7.
This is the url:
http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae
And this is my code:
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae";
WebBrowserTask browser = new WebBrowserTask();
browser.URL = url;
browser.Show();
Thanks!
EDIT:
Without any of the solutions below, this code works fine:
WebBrowserTask browser = new WebBrowserTask();
browser.URL = "http://www.youtube.com/results?search_query=Windows+Phone+7&aq=f";
browser.Show();
I don't understand what is different?
There is a bug with the SDK. In URL that contains &, you need to escape it.
For example:
... Uri.EscapeDataString("&") + "ShowTime=8:00p"
This is most likely because your query string parameters are not URL-encoded. Modern web browsers will attempt to compensate when you paste that into the address bar because it's hard to URL-encode in your head. But when you're using an API, you should really URL-encode those pieces yourself.
Use the Uri.EscapeDataString method to encode each part of the query string individually. For example.
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx" +
"?ShowDate=" + Uri.EscapeDataString("12/15/10") +
"&ShowTime=" + Uri.EscapeDataString("8:00p") +
"&Uid=" + Uri.EscapeDataString("54918a0d-1beb-4552-bdc8-2d474e3ea5ae");
The following code worked for me:
s = "www.. "; //url
s = Uri.EscapeUriString(s);
task.URL = HttpUtility.UrlEncode(s);
You're URI needs to be escaped indeed. As simpler way I think is :
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae";
WebBrowserTask browser = new WebBrowserTask();
browser.URL = Uri.EscapeUriString(url);
browser.Show();

Resources