Selenium testing with HTML Selenese - selenium

I am doing some testing in Selenium using the selenium maven plugin and HTML selenese scripts.
Everything works pretty well except for this scenario I have:
I am clicking on a submit button and it takes me to a redirect url. The server for that URL is not running but the web service that redirect the URL create a code query parameter and add it to the redirect URL.
I want to be able to click submit and use storeLocation selenese command to extract the redirect url and extract that code parameter. When I use clickAndWait, the redirect happens but the test fails because the page tries to load and eventually the maven build. When I use just click command, the test passes, but the page doesn't load and storeLocation doesn't contain the value of the redirect url I need with the code parameter.
Anyone know how to get selenium to click and wait but IGNORE the fact that the page will not load?
I think it needs to involve some javascript and maybe the use of waitForCondition command but I can't find any example of it being done.
basically, the redirect URL has no server running it, but my service create a token param that I need to extract from and pass it to another test case

Is the page load timing out? If so you could increase the default timeout (should be 30 seconds though) or you can use the click event, and then do a waitForLocation to match the new URL (with redirect parameter) you want. This will give you another wait for (like click and wait) of 30 seconds. But you can also add a pause command between the click and the wait for to extend your time for the page to load without touching the default time out.

Related

Is it possible in Jmeter to get overall response time with including rendering of page in browser

I have a requirement from client that The overall response time (end to end time including rendering of page in browser) should be 3 secs for all the requests.Its an API with frontend.
As i know jmeter handles server side response time, even if i add embedded resource it just downloads java script ,images etc but doesn't act as a browser. Is there any way where i can get The overall response time (end to end time including rendering of page in browser) .
Could some please help me out with this.Thanks..
You can use JMeter Plugin WebDriver Sampler with associated -Driver Config Elements to achieve overall response time.
Following Links could be useful
Web Driver Tutorial
Web Driver Sampler
You cannot, as per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So the only way of getting client-side metrics like rendering time you need to use a real browser, for example kick off one using WebDriver Sampler. Metrics can be obtained from Navigation Timing API via WebDriver.executeScript() function

How to simulate a ‘block request url’ using webdriverjs

I have a test where I want to check that if a request is blocked, the appropriate error message is displayed on the page. Using chrome, this can be done via Network tab > Right click on request > Block request url. However, I'm trying to automate this url blocking process and would like to know if this is possible in a WebDriverJs setup

Getting webdriver exception: unknown error: unhandled inspector error...cannot navigate to URL

I am using:
driver.get(“www.google.com”)
The script is not running from this line of code
And if i use:
driver.get(“https://www.google.com”)
It start working
Can anybody please help me out why it is working with https and not working without https?
It is inbuilt implementation of Method get(); and navigate().to(); which work on HTTP GET request.
This is Declaration By method itself:
Load a new web page in the current browser window. This is done using
an HTTP GET operation, and the method will block until the load is
complete. This will follow redirects issued either by the server or as
a meta-redirect from within the returned HTML. Should a meta-redirect
"rest" for any duration of time, it is best to wait until this timeout
is over, since should the underlying page change whilst your test is
executing the results of future calls against this interface will be
against the freshly loaded page.
Parameters: url The URL to load. It is best to use a fully qualified URL
However When we use same string in Browser and it works. Because Browser has it default HTTP protocol and based on that if we don't text http:// or https:// it automatically convert String in to URL.
Here transformation made via get(); method to Browser, and As declared by method it needs URL and not String. Thus it retrieve this Exception.

How to use FirebaseUI in redirect mode without a dedicated sign-in page?

I want to use FirebaseUI in redirect mode, as opposed to the current popup mode I'm using. But I don't want to have a separate dedicated login URL, instead I want the user to be able to log in from any URL (using a custom dialog as the UI container for FirebaseUI).
The problem I run into is that when starting the login process, I show the dialog and the user selects their auth provider, gets redirected to the auth website, but then they are redirected back to the original URL on my website.
Now the UI container dialog is not displayed and firebaseUI.start() doesn't get called because the webpage doesn't know that the user is in the process of logging in. The result is that nothing happens - the user is halfway through the login process.
Is there any way I can specify a URL for the first redirect? I'm not talking about the final signInSuccessUrl config parameter, but something similar for the first redirect back to my website?
That way I'd be able to send the original URL that started the login process along with a flag or something that tells the webpage that the user is in the middle of a login flow so that it can display the login process UI container and call firebaseUI.start() to perform the last redirect.
You can start FirebaseUI from any URL but the underlying signInWithRedirect always return to the same URL. Calling start on redirect will complete the sign in. If you have some condition, where you don't always display the sign in UI, you can use some flag pendingRedirect which you save in sessionStorage and check before rendering the UI to complete the sign-in on return. You would clear that after rendering.

Capture JSON response through Selenium

I'm testing a webpage using Selenium (either IDE or webdriver). The webpage has a "search" function, basically just a GET call with params. The javascript also output to console the JSON returned from the search call, i.e. something like console.log(data). And I'm able to inspect the response data in Firefox console.
My question is: is there anyway I can capture this data from Firefox console in Selenium (so that I can further inspect and doing asserts)? Writing a direct GET request (eg, from Python) does not work since the search url is protected through a login page.
Thanks.
AFAIK Selenium doesnt provide any in built API/method to play with console.
You can redirect console output file and read from file.
Link: How to redirect Firefox console output to file.
It was possible at one point using Firebug. Not sure if it still works.