geb as an additional module using android studio cant find GebConfig.groovy - android-studio

I get the error Caught: geb.error.NoBaseUrlDefinedException: There is no base URL configured and it was requested.
My main module, i assume is default because its got a green dot at the bottom right, is called app and runs some appium tests.
This module called website(little blue line thing) has a java package called geb where both GebConfig.groovy and my groovy script are located. It's very simple:
package geb;
import geb.Browser
Browser.drive {
go("/some/site")
}
and my config:
package geb
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.ie.InternetExplorerDriver
path = 'c:\\drivers\\'
waiting {
timeout = 2
retryInterval = 0.5
preset{
slow{
timeout = 20
retryInterval = 1
}
verySlow{
timeout = 50
}
}
}
environments {
chrome {
drive='chromedriver.exe'
system='webdriver.chrome.driver'
fpath= path+drive
System.setProperty(system,fpath)
driver = { new ChromeDriver() }
}
ie {
drive='IEDriverServer.exe'
system='webdriver.ie.driver'
fpath= path+drive
System.setProperty(system,fpath)
driver = { new InternetExplorerDriver() }
}
}
driver = {new InternetExplorerDriver()}
baseUrl = "http://www.google.com"
reportDir = 'c:\\reports\\'
I have tried manually setting the buildurl to no avail, I've gone through the manual but i couldnt get the classpath set, or atleast when i tried that gave me a whole new set of issues.
What am i doing wrong?

Related

Selenium RemoteWebDriver() ERR_BLOCKED_BY_CLIENT on Chrome Extension in Selenium Grid, while without ChromeExtension works fine

We are using an extension in chrome for wiremock.
This chrome extension works beautifully while running locally both on Windows ( ref. 1), Mac computers.
However when instantiating RemoteWebDriver() in a Selenium Test Grid flavor named Moon, loading the extension fails (on Linux) catastrophically with ERR_BLOCKED_BY_CLIENT when trying to load the chrome extension.
(ref. 1)
On Windows localhost , execution actually fails with a message "That unpacked extensions is disabled by the admin"" but this can be easily workarounded by manually deleting a key at :
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlacklist
https://support.leapwork.com/hc/en-us/articles/360003031952-How-to-resolve-Error-Loading-of-unpacked-extensions-is-disabled-by-the-administrator
**- So I guess one needs to do something similar in the Test Grid node running Linux, but how does that code look like exactly? **
We have a switch statement in the code, so we see that code works generally fine in the test grid when tests are instantiated without the chrome extension.
Junit4.x
com.github.tomakehurst wiremock-jre8 2.32.0
jdk8 (we have so many indirect dependencies on about 77 or so different artifact versions so updating is almost impossible. (I suspect I will get the Nobel price in physics before that happens)
Chrome version 91.0.4472 is instantiated in the grid.
Error message :
idgpnmonknjnojddfkpgkljpfnnfcklj is blocked. This page has been blocked by Chrome. ERR_BLOCKED_BY_CLIENT”
We have tried a few different code constructs which all failed to unblock the extension from loading.
Here is one such code example we unsuccessfully tried with:
private RemoteWebDriver createDriver( Scenario scenario) {
RemoteWebDriver driver = null;
ChromeOptions options = mock ?
new ChromeOptions()
.addExtensions(new File("src/test/resources/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj.crx")) :
new ChromeOptions();
options.setPageLoadStrategy(PageLoadStrategy.EAGER);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Proxy proxy = new Proxy();
proxy.setHttpProxy("http://proxy.aaaaaaaaaaaaaaaa.com:8080");
proxy.setSslProxy("http:// proxy.aaaaaaaaaaaaaaaa.com:8080");");
proxy.setNoProxy("");
capabilities.setCapability("proxy", proxy);
capabilities.setCapability("enableVNC", true);
capabilities.setCapability("name", String.format("TEST - %s", scenario.getName()));
System.setProperty("selenide.remote","https://grid.aaaaaaaaaaaaaaaa.com/wd/hub");
System.setProperty("selenide.browser", "chrome");
System.setProperty("selenide.proxyHost", "proxy.aaaaaaaaaaaaaaaa.com ");
System.setProperty("selenide.proxyPort", "8080");
System.setProperty("selenide.proxyEnabled", "true");
if (System.getProperty("debugMoon") != null && System.getProperty("debugMoon").length()>0) {
capabilities.setCapability("devtools", true);
capabilities.setCapability("noExit", true);
System.setProperty("devtools", "true");
System.setProperty("noExit", "true");
System.setProperty("moon_debugged", "true");
}
// options.merge(capabilities);
try {
if(mock) { addHeaderMock(); } // adding header before Chromedriver new () when started in the MOON test Grid
logger.info("*********** Grid ***********");
final URL url = new URL("https://grid.aaaaaaaaaaaaaaaa.com/wd/hub");
logger.info(">>> Connecting to Moon test grid url: " + url.toString());
driver = new RemoteWebDriver(url, capabilities) ); // have tried both capabilities object but also options.merge(capabilities) with no joy
} catch (final Exception e) {
logger.info("Unable to create driver " + e);
}
logger.info("Connection established\n");
return driver;
}
Any hints or pointers in the right direction are much appreciated!

How does scripted Jenkins Pipeline with Groovy work

stage('deploy') {
steps {
script {
import java.net.URL;
import java.net.URLConnection;
def serviceURL = ""
if (env.BRANCH_NAME == "master") {
serviceURL="http://myserver:8100/jira/rest/plugins/1.0"
}
if (env.BRANCH_NAME == "develop") {
serviceURL = "http://myserver:8100/jira/rest/plugins/1.0"
}
if(env.BRANCH_NAME.startsWith("release")
{
serviceURL="http://myserver:8100/jira/rest/plugins/1.0"
}
// Request to get token
URL myURL = new URL(serviceURL+"?"+"os_authType=basic");
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
}
This is an extract of my jenkinsfile. It is written in Groovy .
Right now I get this error:
WorkflowScript: 66: expecting ')', found 'URL' # line 66, column 17.
It is complaining about this line:
URL myURL = new URL(serviceURL+"?"+"os_authType=basic");
I do not know why. But one thing I was wondering now.
How does it actually work with imports. I mean normally you have to do
import java.net.URL
How would it actually work with extern libraries which are not part of Java SDK.
Normally you would put them on the classpath. How would that work with jenkinsfile scripted pipeline. So I wonder when you can actually use jenkinsfile with groovy or when to better
create an own project and create job for it and then add it in the jenkinsfile.
You don't have to import java.net.*, groovy imports them by default. https://groovy-lang.org/structure.html#_default_imports.
Your problem is a result of a missing ) in the line:
if(env.BRANCH_NAME.startsWith("release")
it should be
if(env.BRANCH_NAME.startsWith("release"))
The whole script should look like so in idiomatic Groovy:
stage('deploy') {
steps {
script {
String serviceURL
switch(env.BRANCH_NAME)
case 'master':
case 'develop':
serviceURL = "http://myserver:8100/jira/rest/plugins/1.0"
break
case ~/^release.*$/:
serviceURL = "http://myserver:8100/jira/rest/plugins/1.0"
break
default:
throw new Exception( 'Unknown' )
}
// Request to get token
"${serviceURL}?os_authType=basic".toURL().openConnection().with{
if( 200 != responseCode ) return
outputStream.withWriter{ it << jsonInputString }
}
}
}
}
Here the withWriter{} takes care about stream flushing and closing.

Phaser 3 ScaleManager exception

I am trying to enable fullscreen in my game written in Phaser 3.
I am doing it from Scene class via
this.game.scale.startFullScreen();
but getting error in f12 browser console
Uncaught TypeError: this.game.scale.startFullScreen is not a function
at TitleScene.<anonymous> (TitleScene.js:23)
at InputPlugin.emit (phaser.js:2025)
at InputPlugin.processDownEvents (phaser.js:167273)
...
In docs ScaleManager class has startFullScreen method.
Why console tells me it doesn't?
This is the full code of TitleScene.js:
export class TitleScene extends Phaser.Scene {
constructor ()
{
const config =
{
key: 'TitleScene'
}
super(config);
}
preload ()
{
this.load.image('Title', 'assets/Title.png');
}
create ()
{
this.background = this.add.image(960, 540, 'Title');
this.input.manager.enabled = true;
this.input.once('pointerdown', function () {
this.scene.start('MainScene');
this.game.scale.startFullScreen(); // here is the error
}, this);
}
}
There are two problems prevented me from resolving this problem:
I followed examples from here
https://www.phaser.io/examples/v2
But I am using the third version Phaser. And everyone who uses the same must follow examples from here
https://www.phaser.io/examples/v3
You must pay attention to url while using their site with examples. Both pages are the same from the first look. But urls are different. Also there are warning after each example using the second (old) version of engine.
And finally this function name is not startFullScreen but startFullscreen :)

How to load google maps javascript api in Aurelia javascript application?

I found npm module google-maps-api and installed it (npm install google-maps-api) but I can't figure out how to import it with systemjs/jspm (jspm cannot find this module). Here's the configuration from my config.js:
"paths": {
"*": "app/dist/*.js",
"github:*": "app/jspm_packages/github/*.js",
"npm:*": "app/jspm_packages/npm/*.js" }
So, when I try do something like this:
import {mapsapi} from 'google-maps-api';
I get the following error in browser console:
GET https://localhost:44308/app/dist/google-maps-api.js 404 (Not Found)
Looking at the filesystem I see that npm installed the module under app/node_modules/google-maps-api so how do I reference it in the import clause from Aurelia module?
I found a solution and answering my own question here:
I finally figured how to install it with jspm, so you just need to give a hint to jspm to install it from npm like so:
jspm install npm:google-maps-api
After jspm completes installation, import (no {} syntax) works fine:
import mapsapi from 'google-maps-api';
then I inject it in constructor and instantiate geocoder api:
#inject(mapsapi('InsertYourGMAPIKeyHere'))
export class MyClass {
constructor(mapsapi) {
let that = this;
let maps = mapsapi.then( function(maps) {
that.maps = maps;
that.geocoder = new google.maps.Geocoder();
});
...
}
In order to create map on a div I use EventAggregator to subscribe for router:navigation:complete event and use setTimeout to schedule map creation:
this.eventAggregator.subscribe('router:navigation:complete', function (e) {
if (e.instruction.fragment === "/yourRouteHere") {
setTimeout(function() {
that.map = new google.maps.Map(document.getElementById('map-div'),
{
center: new google.maps.LatLng(38.8977, -77.0366),
zoom: 15
});
}, 200);
}
});
Here's a complete view-model example that uses attached() to link to your view.
import {inject} from 'aurelia-framework';
import mapsapi from 'google-maps-api';
#inject(mapsapi('your map key here'))
export class MapClass {
constructor(mapsAPI) {
this.mapLoadingPromise = mapsAPI.then(maps => {
this.maps = maps;
});
}
attached() {
this.mapLoadingPromise.then(() => {
var startCoords = {
lat: 0,
long: 0
};
new this.maps.Map(document.getElementById('map-div'), {
center: new this.maps.LatLng(startCoords.lat, startCoords.long),
zoom: 15
});
});
}
}
For everyone using Typescript and getting "Cannot find module 'google-maps-api'" error,
you need to add typings to the solution. Something like this works
declare module 'google-maps-api' {
function mapsapi(apikey: string, libraries?, onComplete?);
namespace mapsapi {
}
export = mapsapi;
}
and then import it like this
import * as mapsapi from 'google-maps-api';

Running SoapUI test cases using testRunner

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.

Resources