I have to invoke a js file from spec file
below is sample files
spec file
@script highlight.js
@objects
header xpath /html/body/app/mbx-header/div
= Verify the focus of header button =
header:
text is "${highlight()}"
${click('//some/xpath')}
css box-shadow is "rgb(233, 238, 206)"
highlight.js
this.highlight = function () {
return 'test123';
};
click.js
this.click = function (xpath) {
//code to click element
};
Actually in the above code validation of text works but is there a way to click on element using js. is there a way to inject js file in the spec file to click on a element during execution and then verify the properties i'm new to java script and Galen .
Galen Spec files are more into HTML and CSS rather than performing actions. To inject Javascript in the middle of the execution you need to create a test.js file.
Here is an example:
test("Inject Javascript", function () {
var driver = createDriver("http://website_url_goes_here", "640x480");
inject(driver,"your javascript code here");
checkLayout(driver, "yourspec.gspec");
});
Hope this helps.