My Coded UI Test should Save/Download a File(Pdf, Excel) from IE10 and I am using this code:
var savePopUp = new UITestControl(GetBrowserWindow()) { TechnologyName = "MSAA" };
savePopUp.SearchProperties.Add(UITestControl.PropertyNames.ControlType, "ToolBar");
savePopUp.SearchProperties.Add(UITestControl.PropertyNames.Name, "Benachrichtigung");
var saveButton = new UITestControl(savePopUp) { TechnologyName = "MSAA" };
saveButton.SearchProperties.Add(UITestControl.PropertyNames.ControlType, "SplitButton");
saveButton.SearchProperties.Add(UITestControl.PropertyNames.Name, "Speichern unter");
Mouse.Click(saveButton);
If I run this locally for testing my code works fine but remotely the controls will not be found.
How do I make the test work remotely?
Related
Similar to How to get the arguments for opening file with electron app but the solution there is not working for me.
Using:
OS - Windows 10
Electron - https://github.com/castlabs/electron-releases.git#v1.8.7-vmp1010
electron-builde - v20.28.3
I have a an electron app build with electron-builder, and using the latter I have specified a custom file association, .custom.
So when you double-click on a file with this extension, file.custom, the installed app opens. This file would have some data in it that the app needs, and I'd like to read this data using my app.
Is there any way that my app can detect what launched it, so that I can say "file.custom" launched me, and it's sitting at "C:\Users\Owner\Downloads\,?
The file does not appear in process.argv
You can get a reference to the file using process.argv, example:
var ipc = require('ipc');
var fs = require('fs');
// read the file and send data to the render process
ipc.on('get-file-data', function(event) {
var data = null;
if (process.platform == 'win32' && process.argv.length >= 2) {
var openFilePath = process.argv[1];
data = fs.readFileSync(openFilePath, 'utf-8');
}
event.returnValue = data;
});
source: Source
I am working on a SoapUI project where I need to run my test suite using test runner. I am using external groovy scripting for environment variable. The problem I am facing here is whenever I am running test case from test runner its return Workspace as null, which is used in External groovy. So in external groovy I am getting workspace as null causing error [getProjectByname() cannot be invoked on null]. Below is the
constructor of global script where workspace is used
AvengerAPITestManager(String TestProject, String TestSuite, String TestCase,String TestStep)
{
TestName = "AvengerAPITests";
testProject = SoapUI.getWorkspace().getProjectByName(TestProject);
tSuite = testProject.getTestSuiteByName(TestSuite);
tCase = testProject.getTestSuiteByName(TestSuite).getTestCaseByName(TestCase);
tStepName = TestStep.toString();
tStep=testProject.getTestSuiteByName(TestSuite).getTestCaseByName(TestCase).getTestStepByName (TestStep);
}
Above we have user SoapUI.getWorkspace() which is working fine when trying to run from soapUI but whever I m trying to run from testrunner SoapUI.getWorkspace comes out to be null. I even tried passing workspace like I am passing testproject name still it didnt worked.
I tried something like this also
AvengerAPITestManager(Object workspace,String TestProject, String TestSuite, String TestCase, String TestStep)
{
TestName = "AvengerAPITests";
testProject = workspace.getProjectByName(TestProject);
tSuite = testProject.getTestSuiteByName(TestSuite);
tCase = testProject.getTestSuiteByName(TestSuite).getTestCaseByName(TestCase);
tStepName = TestStep.toString();
tStep = testProject.getTestSuiteByName(TestSuite).getTestCaseByName(TestCase).getTestStepByName(TestStep);
}
In the above code I tries passing Workspace object from the test case as I passed Testcase name and all but still I m getting null for workspace. Please tell me how do I deal with the problem.
Here is usefull working example https://github.com/stokito/soapui-junit
You should place your sample-soapui-project.xml to /src/test/resources folder that will expose it to classpath
If you want to use soap ui in external code, try to directly create new test runner with specific project file:
SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile( "src/dist/sample-soapui-project.xml" );
runner.run();
Or if you want to define test execution more precisely, you can use something like this:
WsdlProject project = new WsdlProject( "src/dist/sample-soapui-project.xml" );
TestSuite testSuite = project.getTestSuiteByName( "Test Suite" );
TestCase testCase = testSuite.getTestCaseByName( "Test Conversions" );
// create empty properties and run synchronously
TestRunner runner = testCase.run( new PropertiesMap(), false );
PS: don't forget to import soap ui classes, that you use in your code and put them to classpath.
PPS: If you need just run test cases outside the soap ui and/or automate this process, why not just use testrunner.sh/.bat for the same thing? (here is description of this way: http://www.soapui.org/Test-Automation/functional-tests.html)
I am not sure if this is going to help anyone out there but here is what I did to fix the problem I was having with workspace as null causing error[getProjectByname() cannot be invoked on null] When i run from cmd
try this:
import com.eviware.soapui.model.project.ProjectFactoryRegistry
import com.eviware.soapui.impl.wsdl.WsdlProjectFactory
import com.eviware.soapui.impl.wsdl.WsdlProject
//get the Util project
def project = null
def workspace = testRunner.testCase.testSuite.project.getWorkspace();
//if running Soapui
if (workspace != null) {
project = workspace.getProjectByName("Your Project")
}
//if running in Jenkins/Hudson
else{
project = new WsdlProject("C:\\...\\....\\....\\-soapui-project.xml");
}
if (project.open && project.name == "Your Project") {
def properties = new com.eviware.soapui.support.types.StringToObjectMap()
def testCase = project.getTestSuiteByName("TestSuite 1").getTestCaseByName("TestCase");
if(testCase == null)
{
throw new RuntimeException("Could not locate testcase 'TestCase'! ");
} else {
// This will run everything in the selected project
runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
}
}
else {
throw new RuntimeException("Could not find project ' Order Id....' !")
}
The above code will run everything in the selected project.
I'm writing a Visual Studio 2012 add-in which extends Build Explorer - basically, I add a context menu option for every build (completed or running, but not queued). Following a blog post about doing this in VS2010, I managed to do so for builds that appear in Builder Explorer - hooray!
Now, my context menu also appear in Team Explorer's Builds pages, My Builds section. However, when I get the callback, I can't find the actual builds anywhere!
Here's my beforeQueryStatus event handler, where I try to find out whether I have a build to show or not:
private void OpenCompletedInBuildExplorerBeforeQueryStatus(object sender, EventArgs e)
{
var cmd = (OleMenuCommand)sender;
var vsTfBuild = (IVsTeamFoundationBuild)GetService(typeof(IVsTeamFoundationBuild));
// This finds builds in Build Explorer window
cmd.Enabled = (vsTfBuild.BuildExplorer.CompletedView.SelectedBuilds.Length == 1
&& vsTfBuild.BuildExplorer.QueuedView.SelectedBuilds.Length == 0); // No build _requests_ are selected
// This tries to find builds in Team Explorer's Builds page, My Builds section
var teamExplorer = (ITeamExplorer)GetService(typeof(ITeamExplorer));
var page = teamExplorer.CurrentPage as Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.TeamExplorerPageBase;
var vm = page.ViewModel;
// does not compile: 'Microsoft.TeamFoundation.Build.Controls.BuildsPageViewModel' is inaccessible due to its protection level
var vm_private = vm as Microsoft.TeamFoundation.Build.Controls.BuildsPageViewModel;
// But debugger shows that if it did, my builds would be here:
var builds = vm_private.MyBuilds;
}
Is there a way to get the list of builds?
More generally, is there a way to get some "window which this context menu belong to"? Currently I'm just looking around in parts of VS I assume would have builds...
I managed to get the build using reflection:
var teamExplorer = (ITeamExplorer)GetService(typeof(ITeamExplorer));
var BuildsPage = teamExplorer.CurrentPage as Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.TeamExplorerPageBase;
var PageViewModel = BuildsPage.ViewModel as Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.TeamExplorerPageViewModelBase;
// PageViewModel is actually Microsoft.TeamFoundation.Build.Controls.BuildsPageViewModel. But, it's private, so get SelectedBuilds through reflection
var SelectedBuilds = PageViewModel.GetType().GetProperty("SelectedBuilds").GetValue(PageViewModel) as System.Collections.IList;
if (SelectedBuilds.Count != 1)
{
cmd.Enabled = false;
return;
}
object BuildModel = SelectedBuilds[0];
// BuildModel is actually Microsoft.TeamFoundation.Build.Controls.BuildModel. But, it's private, so get UriToOpen through reflection
var BuildUri = BuildModel.GetType().GetProperty("UriToOpen").GetValue(BuildModel) as Uri;
// TODO: Use BuildUri...
cmd.Enabled = true;
My app server uses node.js cluster API cluster.fork() to fork multiple child processes. This works fine.
However, when I try to use vows for unit test, the test also got run multiple times because of the call to cluster.fork() inside my app server; as I instantiate the server inside my test code, as follows:
basic-test.js
var vows = require('vows');
var MyAppServer = require('../my_app');
// start the server
var app = MyAppServer.start();
var suite = vows.describe('My Tests');
suite.discuss('connections API')
.addBatch({ ... })
.export(module);
How do I prevent test code to run multiple times in this case ? This test is included in npm test, so I need a way to instantiate my app server inside test itself.
At the top you can do
var cluster = require('cluster');
Then wrap the suite in an if:
if (cluster.isMaster) {
var suite = ...
...
}
For more info on isMaster, check the documentation
I'm just starting out with JsTestDriver and I've created very simple demo code to see if I have configured my environment correctly. However about 40-50% of the time I'm getting the following error when Firefox is launched (via JsTestDriver) "Firefox Closed Unexpectedly While Starting".
This error does not occur if I use Chrome.
My environment consists of:
VirtualBox 4.1.18 running Ubuntu 10.04.4 LTS 32bit
Firefox 13.0.1
JsTestDriver-1.3.4.b
openjdk-6-jre-headless
I'm executing:
java -jar /home/developer/bin/JsTestDriver.jar --port 9876 --browser /usr/bin/firefox --tests all --testOutput results
My JsTestDriver config is:
server: http://localhost:9876
load:
- src/*.js
test:
- test/*.js
timeout: 10
The source code (code under test) is:
Person = function()
{
this.firstName = "";
this.lastName = "";
this.fullName = function()
{
if((this.firstName != "") && (this.lastName != ""))
{
return this.lastName + ", " + this.firstName;
}
var name = this.firstName + " " + this.lastName;
return name.trim();
}
};
The test code (JsTestDriver based code) is:
PersonTest = TestCase("PersonTest");
PersonTest.prototype.testFullName = function()
{
fixture = new Person();
fixture.firstName = "John";
fixture.lastName = "Doe";
assertEquals("Doe, John", fixture.fullName());
};
PersonTest.prototype.testFullName_FirstNameOnly = function()
{
fixture = new Person();
fixture.firstName = "John";
assertEquals("John", fixture.fullName());
};
PersonTest.prototype.testFullName_LastNameOnly = function()
{
fixture = new Person();
fixture.lastName = "Doe"
assertEquals("Doe", fixture.fullName());
};
Thanks!
Your problem may be in that you're spinning up your server opening your browser every time you run your tests. I think a less error prone solution would be to start your server and have it capture some browsers, and then leave it running. Then you can run your tests against that server as needed. Our solution at work involves three virtual machines running IE7,IE8,IE9,Firefox, and Chrome all the time, and our Maven build process runs our javascript unit tests at every build. Also, make sure that you always use the '--reset' argument as well. It will keep your browsers fresh. I wrote a post that shows how to integrate QUnit, Requirejs, and code coverage with JSTD that is independent of Maven: js-test-driver+qunit+coverage+requirejs. Hope it helps.