QTP/UFT change or modify URL during test execution - vbscript

I have an UFT script, in the second action, i need change the URL DURING test execution, because need to permissions obtained in login in first URL for work in second URL. Don't work in a new sheet or window.
Somebody can help me?
This is my code:
'Int user
Browser("Inicio").Page("Inicio").WebEdit("userid").Set "user"
Browser("Inicio").Page("Inicio").WebButton("Entrar").Click
Wait 3
'Int Pass
Browser("Inicio").Page("Inicio").WebEdit("password").Set "pass"
Browser("Inicio").Page("Inicio").WebButton("Aceptar").Click
Wait 10
' Change URL for work:
'In this point, i need help

Not clear what you asking. What my guess is
You need to login which you have done already.
Get current URL from browser so that you can get a particular string from URL to put it in another URL
If so, then you can use GetROProperty of browser page. So code would be like
Browser("Inicio").Page("Inicio"). GetROProperty ("URL")

Related

cypress record multiple url redirect after a click

I have a scenario where on clicking the submit button will redirect to /redirect1 page where we will be doing some validation and redirects automatically to /redirect2 and do some other validation and get redirects to the /success page.
I need to verify that on clicking submit button it moves to /redirect1 page and then to /redirect2 page and finally get landed to the /success page
How to automate this process using cypress
I like to be very specific about what I expect to happen so I usually do the following:
Arrange:
Specify the API endpoints you are about to call / need to wait for (this is not necessary but you can be sure the assertions won't run until the call resolves)
cy.server()
cy.route('POST', '**/registration').as('registerCall')
cy.route('POST', '**/verification').as('verifyCall')
(you can match the route by exact String, Glob or RegEx, https://docs.cypress.io/api/commands/route.html#Syntax)
Act:
Hit it off
cy.visit('/')
.getByText('Start the process')
.click()
Assert:
a) If you expect it to immediately redirect, assert for it
cy.url().should('eq', `${BASE_URL}/redirect1`)
or
b) If you are making the API call and redirecting only after that, let's wait for it to resolve and then assert. We specify the API call we're waiting for with the # followed by the alias we set above (cy.route(...).as(yourAlias)). I aliased my first API call as registerCall so we wait for that to resolve before making further assertions:
cy.wait('#registerCall')
cy.url().should('eq', `${BASE_URL}/redirect1`)
If you expect some text/loader to show up, check for it
cy.findByTestId('loader-component').should('be.visible')
cy.getByText(/^please wait$/i).should('be.visible')
Wait for the next API call, and check for route change after it
cy.wait('#verifyCall')
cy.url().should('eq', `${BASE_URL}/redirect2`)
... chain the rest of you assertions. This can go on forever.
Hope this helps, let me know if I made some things unclear!
P.S. the getByText (along with other cool selectors) comes from the cypress-testing-library which is built on top of the dom-testing-library and allows you to do navigate your application as a user would, i.e. mainly just by finding text.
If you know the URL(s) you could possibly do something like this
cy.url().should('include', '/redirect1');
cy.url().should('include', '/redirect2');
cy.url().should('include', '/success');
I am assuming it will try those and wait until they happen..

Laravel and redirect->back or something?

I need someway to redirect my app to a previous url.
The problem comes when i make a submit that goes wrong, the redirect->back previous url is someway "overwrited" and i cannot get the previous real url anymore, instead the app makes the submit again.
The only thing that i tried is the redirect back, because i can't find another way to do it :S
So i´m wondering if there is a way to achieve that, redirect the app to a previous url without considering the submit fails and all this stuff.
Thank you.
Yo can try with:
return Redirect::to(URL::previous());
You can store URLs in session and then make Laravel redirect 2 or 3 pages back. Simple example of code to store URL in session:
$links = session->has('links') ? session('links') : []; // Get data from session
array_unshift($links, $_SERVER['REQUEST_URI']); // Add current URI to an array
session(compact('links')); // Save an array to session
And example of code for redirecting:
return redirect(session('links')[2]);

how to change url in code igniter within a class

Hey guys here is the problem i am facing i have a User class which has two functions one login
www.abc.com/user/login
second the confirm_login
www.abc.com/user/confirm_login
now i want two things one when i go to confirm_login from login function as
$this->confirm_login();
URL does not changes, i want the URL to be as www.abc.com/home and also if some how i push refresh the page, url should keep me on the home page www.abc.com/home. Best Regards
use:
redirect('/user/confirm_login/');
at the end of the function after it does the login processing.

Codeigniter's redirect is not passing variable data

I have a form to update some profile information. After making changes when the user clicks on the submit button my to be redirected to the profile page.
so after inserting the updated information into database I have the following code to redirect to the profile page:
database query goes here...
redirect('studentprofile/get/$id');
Here the $id is the the profile id and "get" is the function and "studentprofile" is the controller. But this is not working at all. It seems like the "redirect" is not getting the value of $id.
When the user submits data it shows an error saying "The URI you submitted has disallowed characters." and the URL looks like this
http://localhost/sundial/studentprofile/get/$id
would you please kindly tell me what is wrong with my script? Just for your information I am using Codeigniter
Thanks in advance :)
You need the redirect path string to be in double quotes:
redirect("studentprofile/get/$id");
or write it like this:
redirect('studentprofile/get/'.$id);
You are using single quotes use single quotes instead and btw that is not an issue of CodeIgnitor. Read more about strings: http://www.php.net/manual/de/language.types.string.php#language.types.string.syntax.double

Redirect from current page to a new page

I am having trouble with some Ruby CGI.
I have a home page (index.cgi) which is a mix of HTML and Ruby, and has a login form in it.
On clicking on the Submit button the POST's action is the same page (index.cgi), at which point I check to make sure the user has entered data into the correct fields.
I have a counter which increases by 1 each time a field is left empty. If this counter is 0 I want to change the current loaded page to something like contents.html.
With this I have:
if ( errorCount > 0 )
do nothing
else
....
end
What do I need to put where I have the ....?
Unfortunately I cannot use any frameworks as this is for University coursework, so have to use base Ruby.
As for using the CGI#header method as you have suggested, I have tried using this however it is not working for me.
As mentioned my page is index.cgi. This is made of a mixture of Ruby and HTML using "here doc" statements.
At the top of my code page I have my shebang line, following by a HTML header statement.
I then do the CGI form validation part, and within this I have tried doing something like: print this.cgi( { 'Status' => '302 Moved', 'location' =>
'{http://localhost:10000/contents.html' } )
All that happens is that this line is printed at the top of the browser window, above my index.cgi page.
I hope this makes sense.
To redirect the browser to another URL you must output an 30X HTTP response that contains the Location: /foo/bar header. You can do that using the CGI#header method.
Instead of dealing with these details that you do not yet master, I suggest you use a simple framework as Sinatra or, at least, write your script as a Rack-compatible application.
If you really need to use the bare CGI class, have a look at this simple example: https://github.com/tdtds/amazon-auth-proxy/blob/master/amazon-auth-proxy.cgi.

Resources