Is there a way to define the local profile in the config for Protractor? - jasmine

I have Jasmine-Reporters set up in my config files and working great for me, locally:
require('C:/Users/**<me>**/AppData/Roaming/npm/node_modules/jasmine-node/node_modules/jasmine-reporters')
var outputPath = "C:/Users/**<me>**/<myPath>/"
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(outputPath, true, true));
},
What I'd like to do now is to somehow make the path declarations dynamic so that my tests can be shared and run on someone else's machine. I've tried just replacing my local profile with %USERPROFILE% but that didn't work. Any hints as to how to do this?

I think I have this figured out. What I ended up doing was to create a separate 'prop.js' file that just had this one line in it:
exports.username = "<myProfileName>";
Then, in my conf.js files, I can simply do this:
var properties = require('././prop.js');
var username = properties.username;
require('C:/Users/' + username + '/../jasmine-reporters')
That way, anyone on my team that I want to share these tests with only has to edit the prop.js file once with their own profile name.

Related

Use value from application.yml file inside build.gradle

I am wondering if it's possible to have a value inside my application.yml file:
app:
constant:
foo:
fooValue: 'test'
and to get this value and put it into a variable inside my build.gradle file
What I've tried so far:
How to load yml propery to gradle
I tried the solution in the above link, however
def app = new org.yaml.snakeyaml.Yaml().loadAll(new File("src/main/resources/application.yml").newInputStream()).first()
the above in my build.gradle throws an error 'src\main\resources\application.yml (The system cannot find the path specified)'
Does anyone know how I can fix the error above or of a better solution?
In case anyone wants to know, adding $projectDir to the start of the file path fixed the issue.
def app = new org.yaml.snakeyaml.Yaml().loadAll(new File("$projectDir/src/main/resources/application.yml").newInputStream()).first()

How to reference script files in webpack deploy?

I am using webpack and electron and while I can reference my script files fine locally (app/scripts/scriptname.sh), when it comes to the production deploy, I get an error: Can't open app/components/scripts/scriptname.sh.
It's unclear to me if this is an electron-dependent issue or a webpack-issue.
I am running these using node child_process as:
var ls = spawn('sh', ['app/components/scripts/scriptname.sh']);
I don't necessarily need the scripts to be in their own folder it would just be helpful.
You need to provide the complete absolute path to the script. To do that you can use the app.getAppPath() API of electron
app.getAppPath()
Returns String - The current application directory.
So your code would be something like:
var scriptAbsolutePath = app.getAppPath() + '/app/components/scripts/scriptname.sh';
var ls = spawn('sh', [scriptAbsolutePath]);
You can also have a look at app.getPath(name) API if it satisfies your particular requirement.

accessing App.Config file after deploy in C#

Im using below code to update app.config's some values( I have config file path in the app.config file).When deploy its getting errors I think its becouse app.config file change in to an exe. how to change my code work as debug time as well as deploy time
var appPath = ConfigurationManager.AppSettings["configPath"].ToString();
string configFile = System.IO.Path.Combine(appPath, "App.config");
var configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configFile;
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
config.AppSettings.Settings["InvoiceInterval"].Value = InvoiceIntervalVal.ToString();
Hi thanks every body for instance reply. I fix my own problem it was just a confusion. I was a java guy and I new to .net in .net App.config file compile and create .config in Debug folder file even though debug it access that .config file in Debug folder . So actually when if you change the value in App.config in programatically it doesn't change the App.config file. it change the .config which is in debug file.its like [project name].vshost.exe.config in debug folder.
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["InvoiceInterval"].Value = InvoiceIntervalVal.ToString();
config.AppSettings.Settings["directPaymentInterval"].Value = directPaymentIntervalVal.ToString();
config.AppSettings.Settings["paymentStatusInterval"].Value = paymentStatusIntervalVal.ToString();
config.Save();
ConfigurationManager.RefreshSection("appSettings");
using above code you can able change App.config file's value in debug time also in run time. but those changes not seems in App.config file. but you can see changes in exe file which it is belongs to.In my case it was in src\Vetserve.Credicare\bin\Debug\Vetserve.Credicare.vshost.exe.config
Perhaps try and set your App.config's file 'Copy to Output Directory' property to 'Copy always'.
Reference: AppConfig file not found in bin directory
After compilation App.Config will be available as
YourConsoleApplication.exe.Config inside application bin.
You can do like:
var beforeInvoiceInterval = ConfigurationManager.AppSettings
["InvoiceInterval"].ToString();
ConfigurationManager.AppSettings["InvoiceInterval"] = "Your value";
var afterInvoiceInterval = ConfigurationManager.AppSettings
["InvoiceInterval"].ToString();
afterInvoiceInterval will contain the value you assigned but it'll not
modify YourConsoleApplication.exe.Config.

Use relative path in Firefox extension

I develop Firefox extension with bundled executable file which should be run on browser startup.
To run process I need get nsIFile or nsILocalFile instance which points to executable file.
I know one solution how to get it using directory service:
var file = Components.classes["#mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append("<extension id>");
file.append("<relative path>");
But this solution has two disadvantages:
It doesn't work in development mode, when instead of installed extension I have only text file with real extension path
I'm not sure that it will work on all Firefox configurations because of hardcoded "extensions" part of the path
So is there any nicer way to run executable file which comes with Firefox extension?
Thanks.
You are making way too many assumptions about the directory structure of the Firefox profile - don't. The Add-on Manager API lets you get the path of a file inside the extension, you should use it:
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("<extension id>", function(addon)
{
var uri = addon.getResourceURI("<relative path>");
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
...
});
A restartless addon's startup function (in the bootstrap.js file) will receive, as its first parameter, the path where the addon is installed. You can then play various tricks to read files inside the .jar file, if any: see https://github.com/protz/GMail-Conversation-View/blob/master/bootstrap.js#L55 as an example.
In a non-restartless case, I must confess I don't have much of an idea :).
I found this thread looking for a way to reference a path to an image hosted in extension's directory from a content script. Here's a solution:
Include your files in web_accessible_resources in the extension's manifest.
"web_accessible_resources": [
"images/*"
]
Absolute paths to these resources contain randomly generated UUID, therefore we're using runtime.getUrl() giving it the path relative to manifest.json. Example:
let myImg = document.createElement('img');
myImg.src = browser.runtime.getURL("images/my-img.png")

CKeditor & KCFinder in localhost

I am a building a website locally and I am using CKeditor with KCFinder at a part of it. CKEditor runs properly and KCFinder Upload Tab is also visible, so I guess my installation was correct.
BUT! When I try to upload an image using the KCFinder module ("Browse" then "Send to server") I get an error message showing in the same popped-up window saying:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
03/01/12 14:31:05
Apache/2.2.21 (Win32) PHP/5.3.8
I have Windows 7, running it in localhost with Easy PHP and the local path to my target folder is:
C:\PROGRA~2\EASYPH~2.1\www\electro\kcfinder\upload
In my kcfinder/config.php I have:
'uploadURL' => "/upload",
'uploadURL' => "../upload",
'uploadDir' => "",
'uploadDir' => "C:\PROGRA~2\EASYPH~2.1\www\electro\kcfinder\upload",
as instructed by the official related thread here.
Anyone has any idea what might be wrong?
EDIT:
Solved it. Needed to change the paths on both KCFinder/config.php AND CKEditor/config.js. Since my paths are:
The project path:
C:\PROGRA~2\EASYPH~2.1\www\electro
and it has the subfolders "ckeditor" and "kcfinder" and I want to have the folder "kcfinder/upload" as the target folder of the filed to be uploaded, then the following changes need to made...
ckeditor/config.js:
CKEDITOR.editorConfig = function(config) {
config.filebrowserBrowseUrl = '../electro/kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = '../electro/kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = '../electro/kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = '../electro/kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = '../electro/kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = '../electro/kcfinder/upload.php?type=flash';
};
kcfinder/config.php:
'uploadURL' => "upload",
'uploadDir' => "",
For some reason it needed the ../ while it was already in the same folder. I don't understand why, but it works.
Now, I would like to say how displeased I am at the developer of the KCFinder where people with the same issue or others on its support forum the given "help" was things like "RTFM", "Do better searches" etc. As if everyone was born an experienced programmer.
I actually found the answer shortly after I posted my answer. It seems that the path system on ckeditor/config.js doesn't really work as a normal path usually works. so, you have to play around with the "../" and try to find out where it is aiming at. In my case, I didn't need any "../" to refer to a file that was in a separated folder one level up. So the final code for me was:
CKEDITOR.editorConfig = function(config) {
config.filebrowserBrowseUrl = 'kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = 'kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = 'kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = 'kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = 'kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = 'kcfinder/upload.php?type=flash';
};
when actually should be '../kcfinder/browse.php?type=files'
Hope it helps...

Resources