I am testing REST services using PROTRACTOR-HTTP-CLIENT tool in my protractor framework. The same framework also tests the UI application. I have different config file for UI and API test.
But my problem is when I am testing the REST services the chrome browser is launching which has no use.I can use headless chrome but I want to completely disable the browser launch.
Is there any way to disable the browser launch when testing the rest services.
I don't think this will be achievable. The webdriver session is triggered during one of the automated hook stages during Protractors initialization, likely the onPrepare hook. This hook functionality will always be executed and there is no ability to override it before it takes place.
What you could do is call browser.quit() at the start of your tests to end the session but as far as I know there is no way to stop it from initializing.
I have same setup in my project with typescript. For Api tests I have a separate jasmine.json file and npm script "jasmine-ts --config=jasmine.json". This should help you avoid initializing browser and runs only api tests. Basically instead of using protractor to run tests, running tests directly using jasmine framework.
this is how my jasmine.json file looks:
{
"spec_dir": "specs",
"spec_files": [
"api/*[sS]pec.ts"
],
"helpers": [
"init.ts"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
Related
I created a Blazor WebAssembly application and tried calling an external weather API for testing purposes. I put an XUnit test project in front of the WeatherService class that I created and the test execute successfully giving me the data.
When I run it from a Blazor component I see in the F12 developer tools console that the REST call executed.
But I see a bunch of errors in the Console.
It does not load the data on the page as expected. Has anyone faced this situation. I am running the latest template of the Blazor App built using VS 2019.
Also my Blazor Web Assembly app is not hitting any breakpoints, so I dont really know at what stage it is breaking.
We are doing a Selenium based web application testing. We have a requirement to test the application in different browsers.
The requirement is also use browsers from cloud applications like crossbrowser testing.(https://crossbrowsertesting.com/). We are not getting enough idea how to implement and execute our script within crossbrowser tool.
I'm wondering if it is possible to run a setup of angular cli project with cucumber e2e tests, using protractor steps, without using a selenium server. When I search for such configurations, I only find ones that have a seleniumAddress setup.
So, is it possible to run it without it?
Requires a server running W3C WebDriver specifications
From your question, can you run Protractor without a selenium server? Yes, if you are using a browser driver that follows the W3C WebDriver specification. So setting directConnect: true (angular-cli default) in your configuration file basically tells Protractor to launch the driver binary, then Protractor creates a driver provider to talk to that binary.
Driver provider options
The driver providers can be different. Your question also referred to the seleniumAddress. So how does this work? Basically, Protractor reads your configuration file and decides which driver provider to launch. If you are not using directConnect and have decided to use the seleniumAddress option in your configuration then you could be either launching an attached session or a hosted driver. Attaching a session means that you have a previous session running and Protractor will launch tests against the session id. Hosted means that you have started your test against a running selenium standalone server. Usually the selenium standalone server is http://localhost:4444.
There are other types of driver providers to help launch your tests and if you follow the conditional in buildDriverProvider method, you can pick and chose which one you want to launch. Obviously (from the conditional), if you have directConnect and seleniumAddress, you will launch with a direct connect driver provider.
A quick note on webdriver-manager
Also a quick note on webdriver-manager. If you plan to launch your Protractor tests on Firefox, you'll need to download Gecko driver. If you use the seleniumAddress option, you'll also need to download the selenium-standalone server. The angular-cli only downloads chromedriver with the command, webdriver-manager update --standalone false --gecko false. To download the rest, simply remove the flags that are set to false: webdriver-manager update
Cucumber in your configuration
So finally you want cucumber with Protractor. Protractor supports cucumber as a custom framework. You'll need to require the protractor-cucumber-framework. Hopefully you have found this on the configuration in the Protractor-cookbook.
You should add the following to your configuration to get cucumber working:
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
compiler: "ts:ts-node/register",
monochrome: true,
strict: true,
plugin: ["pretty"],
require: ['../../stepdefinitions/*.ts', '../../support/*.ts'],
//tags help us execute specific scenarios of feature files
tags: '#AddScenario,#SubtractScenario,#MultiplyScenario,#DivideScenario,#ModulusScenario'
}
You can run protractor tests without selenium server by using directConnect: true in your protractor config. But note this option only currently works with Chrome and Firefox.
I am building an AngularJS web application with Java as backend.When I look for an end to end testing framework, Protractor found to be a better option.But it is highly dependent on node.js(since it's built on top ofnode). Is that correct?
what I need is , I want to run Protractor with maven and tomcat. Can we run it without the dependency of node.js?
No, Protractor is dependent on Node.js So you have to use it.
There are two separate questions:
Can you run protractor without node? The answer is no. Protractor is a node project and requires node dependencies.
Can you use Protractor in a maven project? The answer is yes. I have not tried it but I've seen community members comment on this. A quick search to maven and protractor, I came across this stackoverflow for maven + protractor with the corresponding maven plugin project on github.
I hit this question since I'm wrestling with the same problem. This is what I've figured out.
Protractor (and Karma for the jsunit testing of Angular) requires node, but this isn't a large obstacle since you can pull in and install node using Maven, and use it to pull in yarn to get angular setup and built at deploy and test time. It is also possible to set up a proxy server from the node server to the Spring Boot App so that the REST endpoints will work.
What I want (and what I'm guessing the original poster wants) is to figure out a way to start up protractor without starting the node server. I don't want that server started because as part of the end to end testing I want to verify the spring app is serving the necessary static files correctly, not just the REST endpoints.
If I find an answer I'll update this.
I am in flux for integrating an automated GUI testing with my build system. My GUI application is developed in GWT. I use HUDSON as my automated build system. I would like to perform sanity test of my application. As I understand, the entire test setup will have following steps.
Build and deploy the application in predefined application server. In my case, it would be create and install the application in Android emulator.
Start/Launch the application.
Perform pre-defined user actions(UI Test cases) and validate them.
Somehow include validations for different browsers. I am really not sure how can I do this.
Generate report of test cases performed.
I am not posting the details of application as I think this detail will not make any difference in the approach. Can somebody guide me using past experience if this is possible and if it is then to what extent. The best UI automation tool (preferably open source) which can fit easily here.
We use TeamCity as build server for a GWT application. We just use it as a build server with two tasks: compile sources into Javascript, and deply war file to Tomcat application server. Although I didn't manually set it up yet, I believe it's possible to add a third task for UI testing using Selenium (which we used for another JSF web application testing).
A fairly good example of using Selenium automated testing is RichFaces. If you download its source code package, it includes hundreds of UI-testnig codes written generated by Selenium.