Enabling Mink Extension in Behat - bdd

I'm trying to add the Mink extension to Behat. I've installed Behat, Mink and Mink-Extension through composer. However, now I'm having trouble with enabling the extension. Here is my behat.yml:
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://en.wikipedia.org
goutte: ~
selenium2: ~
Here is my example test:
Feature: New
In order to test Behat
As a developer
I need to test that Mink Extension works
Scenario:
Given I am on the homepage
When I run Behat, I get this output:
Feature: New
In order to test Behat
As a developer
I need to test that Mink Extension works
Scenario: # features/new.feature:6
Given I am on the homepage # FeatureContext::iAmOnHomepage()
Mink instance has not been set on Mink context class. Have you enabled the Mink Extension? (RuntimeException)
--- Failed scenarios:
features/new.feature:6
1 scenario (1 failed)
1 step (1 failed)
0m0.02s (11.86Mb)
So I searched for 'Mink instance has not been set on Mink context class. Have you enabled the Mink Extension? (RuntimeException)' and got no decent results. What do I need to do to enable the extension?

Default profile and extensions are not aligned properly, try align document according to yml markup
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://en.wikipedia.org
goutte: ~
selenium2: ~
For more information check behat extension docs

Related

Where is the "Hello world" going to be printed after following shadow-cljs documentation to watch the app?

I am following shadow-cljs Quick Start documentation on a minimal example of a project. Here is the link.
I have this shadow-cljs.edn file:
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dev-http {8080 "public"}
:dependencies
[]
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn acme.frontend.app/init}}
}}}
In /Users/pedro/projects/acme-app/src/main/acme/frontend/app.cljs, I also have:
(ns acme.frontend.app)
(defn init []
(println "Hello World"))
I can build and watch it with the command:
$ npx shadow-cljs watch frontend
shadow-cljs - config: /Users/pedro/projects/acme-app/shadow-cljs.edn
shadow-cljs - HTTP server available at http://localhost:8080
shadow-cljs - server version: 2.20.2 running at http://localhost:9630
shadow-cljs - nREPL server started on port 61214
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build completed. (127 files, 0 compiled, 0 warnings, 6.97s)
Since the init function is a "Hellow World" function I was expecting to see it in some place. But, I can't find anywhere "showing" the Hello World to see it worked out.
Where is the "Hello World" supposed to "appear"? Is it supposed only to be available in the REPL inside the IDE as a function to be invoked by the programmer?
The "hello world" is not printed on the terminal (see above the message retrieved), is not displayed on the UI on localhost:8080 (that would probably need a tweak in HTML - see pic below), and does not appear on the browser console (that would probably need js/console.log).
These are the failed attempts to invoke the functions in the REPL after executing npx shadow-cljs node-repl:
cljs.user=> (acme.frontend.app/init)
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var acme.frontend.app/init
--------------------------------------------------------------------------------
cljs.user=> (main.acme.frontend.app/init)
------ WARNING - :undeclared-ns ------------------------------------------------
Resource: <eval>:1:2
No such namespace: main.acme.frontend.app, could not locate main/acme/frontend/app.cljs, main/acme/frontend/app.cljc, or JavaScript source providing "main.acme.frontend.app"
--------------------------------------------------------------------------------
This is the image on localhost:8080:
You appear to have skipped the creation of the public/index.html, as mentioned in the Quick Start. The build is using :target :browser, so it is meant to be loaded in the Browser. The HTML will do that. When loaded you'll see the println in the Browser Console.
For the REPL the code always needs to be loaded before if can be used. So, you need a (require '[acme.frontend.app :as x]) before running (x/init).

SilverStripe running tests using Behat throwing "No behat.yml found for module silverstripe/framework" error

I am working on a SilverStripe project. I am trying to write Behavioural Tests using Behat for my projects. But I am getting an error when I run the tests. Following is what I have done so far.
First I install the module using composer
composer require --dev silverstripe/behat-extension
I have the behat.yml file right under the project root folder with the following definition
default:
suites: []
extensions:
SilverStripe\BehatExtension\MinkExtension:
default_session: facebook_web_driver
javascript_session: facebook_web_driver
facebook_web_driver:
browser: chrome
wd_host: "http://127.0.0.1:9515"
browser_name: chrome
SilverStripe\BehatExtension\Extension:
bootstrap_file: vendor/silverstripe/cms/tests/behat/serve-bootstrap.php
screenshot_path: %paths.base%/artifacts/screenshots
retry_seconds: 4 # default is 2
Then I tried to run the tests executing the following command.
vendor/bin/behat #framework
Then I get the following error.
In ModuleSuiteLocator.php line 166:
No behat.yml found for module silverstripe/framework
behat [-s|--suite SUITE] [-f|--format FORMAT] [-o|--out OUT] [--format-settings FORMAT-SETTINGS] [--init] [--namespace NAMESPACE] [--lang LANG] [--name NAME] [--tags TAGS] [--role ROLE] [--story-syntax] [-d|--definitions DEFINITIONS] [--snippets-for [SNIPPETS-FOR]] [--snippets-type SNIPPETS-TYPE] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--dry-run] [--] [<module> [<paths>]]
There is not behat.yml in the vendor/silverstripe/framework folder. Actually, it is supposed to come with the framework. But it is not there. How can I solve the error?
For all SilverStripe modules the tests and associated configuration are not shipped with distributable packages (e.g. tags).
If you want to use them, you'll need to install the "dev" version. E.g. 4.5.x-dev instead of ~4.5.0.

How can I make my openAM SDK app know where to find OpenAM server?

I am writing a complemental service for OpenAM for some features not available as RESTful services in default server. I am using OpenAM Client SDK (12 or 13). I get the folloing error:
DebugConfiguration:07/03/2017 04:13:12:530 PM IRDT:
Thread[main,5,main]
'/debugconfig.properties' isn't valid, the default configuration will be used instead: Can't find the configuration file
'/debugconfig.properties'.
amAuthContext:07/03/2017 04:13:12:564 PM IRDT: Thread[main,5,main]:
TransactionId[unknown]
ERROR: Failed to obtain auth service url from server: null://null:null
amNaming:07/03/2017 04:13:12:573 PM IRDT: Thread[main,5,main]:
TransactionId[unknown]
ERROR: Failed to initialize naming service
java.lang.Exception: Cannot find Naming Service URL.
at com.iplanet.services.naming.WebtopNaming.getNamingServiceURL(WebtopNaming.java:1254)
at com.iplanet.services.naming.WebtopNaming.initializeNamingService(WebtopNaming.java:272)
at com.iplanet.services.naming.WebtopNaming.updateNamingTable(WebtopNaming.java:1149)
at com.iplanet.services.naming.WebtopNaming.getNamingProfile(WebtopNaming.java:1070)
at com.iplanet.services.naming.WebtopNaming.getServiceAllURLs(WebtopNaming.java:494)
at com.sun.identity.authentication.AuthContext.login(AuthContext.java:654)
at com.sun.identity.authentication.AuthContext.login(AuthContext.java:584)
at com.sun.identity.authentication.AuthContext.login(AuthContext.java:386)
at MainKt.realmLogin(Main.kt:56)
at MainKt.main(Main.kt:144)
IdRepoSampleUtils: Failed to start login for default authmodule
Exception in thread "main"
com.sun.identity.authentication.spi.AuthLoginException: Failed to create new Authentication Context: null
at com.sun.identity.authentication.AuthContext.login(AuthContext.java:657)
at com.sun.identity.authentication.AuthContext.login(AuthContext.java:584)
at com.sun.identity.authentication.AuthContext.login(AuthContext.java:386)
at MainKt.realmLogin(Main.kt:56)
at MainKt.main(Main.kt:144)
The main error is SDk does not find STS server url. How can I fix it?
I found the solution with checking the Example SDK client. The solution is to use Java's well-knwon properties file. There is a AMConfig.properties in there which the SDK jar automatically tries to extract values from it. For the format of the file we can refer to Oracle OpenSSO, and use the AMConfig.properties.template within the OpenAM example client application.

How to press keys on Android application in Appium via Robot Framework?

my Robot Framework script is shown below. When I use the "Input Text" keyword, the previous letters are erased and only the last letter is shown. How can I simulate a manual key press using Appium via Robot Framework?
*** Settings ***
Library AppiumLibrary
Test Setup Setup application
Test Teardown Teardown application
*** Variables ***
${BROWSER_NAME} mobileOS
${PLATFORM} Android
${USER} XXXXXXX
${PASSWORD} XXXXXXX
${deviceName} XXXXXXX
${AUTOMATIONNAME} Appium
${HOST} https://XXXX.perfectomobile.com/nexperience/perfectomobile/wd/hub
${ANDROID_APP} PUBLIC:XXXX\\XXXXXXXXXXX_X_X_XX.apk
${ANDROID_APP_PACKAGE} XXX.XXX
${APP_ACTIVITY} XXX.XXX.XXX
*** Test Cases ***
Test Case 01: Open application and then close it
Log Source
Wait until page contains element xpath=//*[#resource-id='email'] timeout=60
Input Text xpath=//*[#resource-id='email'] Hello
Capture Page Screenshot
*** Keywords ***
Setup application
Open Application ${HOST}
... browserName=${BROWSER_NAME}
... platform=${PLATFORM}
... user=${USER}
... password=${PASSWORD}
... deviceName=${DEVICENAME}
... automationName=${AUTOMATION_NAME}
... app=${ANDROID_APP}
... appPackage=${ANDROID_APP_PACKAGE}
... appActivity=${APP_ACTIVITY}
Teardown application
Log Source
Close Application
You can use the selenium library built-in keyword Press Key along with the corresponding ASCII code of the certain key you want to press.
For more information visit: https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Press%20Keycode
Example:
press keycode 66

How define parameters for behat scenarios

Is there any way to use parameteres/variables in behat scenarios?
For example:
Scenario: Description
Given I am on "https://{{company_name}}.example.com/"
When I click on "xxxxx"
And I wait 2 seconds
Then I should see {{company_name}}
and in behat.yml
default:
extensions:
Behat\MinkExtension\Extension:
goutte: ~
selenium2: ~
companyX:
params:
company_name: XXX
extensions:
Behat\MinkExtension\Extension:
companyY:
params:
company_name: YYY
extensions:
Behat\MinkExtension\Extension:
I think about using some template engine and render every set of tests separately, but maybe there is easier solution.
You cannot pass parameters to the .feature file.
Just put the configuration inside behat.yml.
Instead of using the step:
Given I am on "https://{{company_name}}.example.com/"
use:
Given I am on homepage
And set the url with 'base_url' in behat.yml:
default:
extensions:
Behat\MinkExtension\Extension:
goutte: ~
selenium2: ~
companyX:
extensions:
Behat\MinkExtension\Extension:
base_url: https://companyx.example.com/
companyY:
extensions:
Behat\MinkExtension\Extension:
base_url: https://companyy.example.com/
Then depending on how you run behat:
behat --profile companyX
behat --profile companyY
a different url will be used.
More info about this:
http://docs.behat.org/guides/7.config.html#context

Resources