Javascript evaluation failed: input('#login_field','dummy') on running karate feature - karate

I am getting error
"java.lang.AssertionError: failed features:
feature.demo-01: demo-01.feature:16 - javascript evaluation failed: input('#login_field','dummy'), ReferenceError: "input" is not defined in at line number 1"
on running the below feature
Feature: browser automation 1
Background:
* configure driver = { type: 'chrome', showDriverLog: true }
# * configure driverTarget = { docker: 'justinribeiro/chrome-headless', showDriverLog: true }
# * configure driverTarget = { docker: 'ptrthomas/karate-chrome', showDriverLog: true }
* configure driver = { type: 'chromedriver', showDriverLog: true }
# * configure driver = { type: 'geckodriver', showDriverLog: true }
# * configure driver = { type: 'safaridriver', showDriverLog: true }
# * configure driver = { type: 'iedriver', showDriverLog: true, httpConfig: { readTimeout: 120000 } }
Scenario: try to login to github and then do a google search
Given driver 'https://github.com/login'
And input('#login_field','dummy')
And input('//input[#id='password']', 'world')

You must be on an old version of Karate. Use 0.9.5.
Maybe try the ZIP Release first and get familiar: https://github.com/intuit/karate/wiki/ZIP-Release

Related

Deploying Synapse Workspace with Managed Vnet Enabled (Bicep), but cannot assign private endpoints in UI

Situation:
I am deploying a Synapse workspace instance in Bicep with Managed Virtual Network Enabled.
I can see the Managed Vnet Is enabled from the UI:
However, when I enter the workspace my integration runtimes are not enabled for virtual network access and I cannot create managed private endpoints.
I'm writing the following code for the bicep deployment:
resource synapse_workspace 'Microsoft.Synapse/workspaces#2021-06-01' = {
name: synapse_workspace_name
location: location
tags: {
Workload: '####'
Environment: envName
Classification: 'Confidential'
Criticality: 'Low'
}
identity: {
type: 'SystemAssigned'
}
properties: {
// Git Repo
workspaceRepositoryConfiguration: {
accountName: '#####'
collaborationBranch: 'main'
projectName: '####'
repositoryName: '#############'
rootFolder: '/synapse/syn-data-${envName}'
tenantId: '####################'
type: 'WorkspaceVSTSConfiguration'
}
defaultDataLakeStorage: {
resourceId: storage_account_id
createManagedPrivateEndpoint: true
accountUrl: ###################
filesystem: ################
}
encryption: {
cmk: {
kekIdentity: {
useSystemAssignedIdentity: true
}
key: {
name: 'default'
keyVaultUrl: '#########################'
}
}
}
managedVirtualNetwork: 'default'
connectivityEndpoints: {
web: 'https://web.azuresynapse.net?workspace=%2fsubscriptions%######################
dev: 'https://##############.dev.azuresynapse.net'
sqlOnDemand: '################-ondemand.sql.azuresynapse.net'
sql: '################.sql.azuresynapse.net'
}
managedResourceGroupName: guid('synapseworkspace-managed-resource-group-${envName}')
sqlAdministratorLogin: 'sqladminuser'
privateEndpointConnections: []
managedVirtualNetworkSettings: {
preventDataExfiltration: true
allowedAadTenantIdsForLinking: []
}
publicNetworkAccess: 'Disabled'
cspWorkspaceAdminProperties: {
initialWorkspaceAdminObjectId: '#########################'
}
trustedServiceBypassEnabled: false
}
}
I get no errors in the deployment regarding the virtual network or any associated settings, but I still get the default integration runtime set to "Public" and not "Managed Virtual Network".
Is this a limitation in Bicep or am I missing some parameter?
Any help would be great
Joao

How to declare appium driver globally in karate config.js with desired capabilities?

I am trying to declare and luanch appium driver session from config.js along with desired capabilities but i am not able to launch the driver session.
My feature file looks like below: (before declaring in config.js)
Background: Driver setup
* configure driver = { type: 'android', webDriverUrl: 'http://localhost:4723/wd/hub', start: false}
* driver { webDriverSession: { desiredCapabilities : "#(desiredConfig)" } }
Scenerio: perform click
* click('elementPath')
Added below lines in config.js then i removed first line from feature file, it worked fine.
karate.configure('driver', { type: 'android', start: false, webDriverUrl: 'http://localhost:4723/wd/hub' });
Then after that my feature file looks like below:
Background: Driver setup
* driver { webDriverSession: { desiredCapabilities : "#(desiredConfig)" } }
Scenerio: perform click
* click('elementPath')
Now i am stuck in moving the
* driver { webDriverSession: { desiredCapabilities : "#(desiredConfig)" } }
driver session part (above one) to config.js
Tried below things:
Created driver variable in config.js and assigned
{ webDriverSession: { desiredCapabilities : desiredConfig } }
Tried using driver variable in feature file
Declared desired config json directly and no luck

Codeception seeInDatabase() not working as expected

I have problems getting codeceptions seeInDatabase() to work. This is my Cest:
public function testContactMailCheckbox(AcceptanceTester $I) {
$I->scrollTo("#adminMailSettingsForm", 0, -200);
$I->seeInDatabase("pib_users", [
"user_email" => "admin-cest#example.org",
"user_receive_contact_notification" => 0
]);
$I->click("//label[#for='contactMailNotification']", "#adminMailSettingsForm");
$I->waitForJS("return $.active == 0;",10);
$I->wait(100);
$I->seeInDatabase("pib_users", [
"user_email" => "admin-cest#example.org",
"user_receive_contact_notification" => 1
]);
}
The first seeInDatabase() passes, everything is fine. I can verify that this seeInDatabase-Assertion works correctly, by changing the default-data in my database dump. When I change the default data to "user_receive_contact_notification" => 1, the first seeInDatabase fails, which means it is working correctly.
I use $I->wait(100) to verify, that there are no synchronisation-issues. During this timespan I can check via phpMyAdmin, that the row was indeed updated correctly. That means the test should pass.
Here is my Db-config:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://pib.local/'
window_size: false # disabled in ChromeDriver
port: 5555
browser: chrome
capabilities:
chromeOptions:
args: ["--headless", "--no-sandbox", "--disable-gpu", "--window-size=1920,1080"]
- \Helper\Acceptance
- Sequence
- \Helper\DbHelper
config:
\Helper\DbHelper:
user: "root"
password: ""
dsn: "mysql:host=localhost;dbname=pib"
cleanup: true
dump: 'tests/database_dump_tests.sql'
populate: true
reconnect: true
step_decorators: ~
My DbHelper contains only a single function:
class DbHelper extends \Codeception\Module\Db
{
public function putInDatabase($table, $data, $insertOnlyIfNotExisting = true) {
// if ignoreDuplicateError is true, only execute insert when not existing already
if($this->countInDatabase($table, $data) == 0 | !$insertOnlyIfNotExisting) {
$this->_insertInDatabase($table, $data);
}
}
}
This might be related to this question. I don't use Laravel though, so just using the seeRecord()-helper isn't going to help me.

hapi-sequelize 3.0.4 support for Hapi version 17.2.0

I am trying to use hapi-sequelize 3.0.4 with hapi.js 17.2.0 using the following configuration:
{
plugin: require("hapi-sequelize"),
options:[
{
name: "mysql", // identifier
models: ["./plugins/sequelize/models/*.js"], // paths/globs to model files
sequelize: new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASS,
{
host: process.env.DB_HOST,
dialect: "mysql",
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 3306
}
), // sequelize instance
sync: false, // sync models - default false
forceSync: false // force sync (drops tables) - default false
}
]
}
It gives the following error:
name[1] --missing---
Is this the latest version of hapi-sequelize compatible with hapi.js 17.2.0?

Why error Connection refused! Is selenium server started?

Trying to run nightwatch after following this: https://github.com/dwyl/learn-nightwatch. This is my config file:
//require('env2')('.env'); // optionally store youre Evironment Variables in .env
const seleniumServer = require("selenium-server");
//const chromedriver = require("chromedriver");
const SCREENSHOT_PATH = "./screenshots/";
// we use a nightwatch.conf.js file so we can include comments and helper functions
module.exports = {
"src_folders": [
"tests/"// Where you are storing your Nightwatch e2e tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": seleniumServer.path,
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": {
"webdriver.chrome.driver": "./chromedriver.exe"
}
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // turn off to test progressive enhancement
}
}
}
}
function padLeft(count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
return count < 10 ? '0' + count : count.toString();
}
var FILECOUNT = 0; // "global" screenshot file count
/**
* The default is to save screenshots to the root of your project even though
* there is a screenshots path in the config object above! ... so we need a
* function that returns the correct path for storing our screenshots.
* While we're at it, we are adding some meta-data to the filename, specifically
* the Platform/Browser where the test was run and the test (file) name.
*/
function imgpath(browser) {
var a = browser.options.desiredCapabilities;
var meta = [a.platform];
meta.push(a.browserName ? a.browserName : 'any');
meta.push(a.version ? a.version : 'any');
meta.push(a.name); // this is the test filename so always exists.
var metadata = meta.join('~').toLowerCase().replace(/ /g, '');
return SCREENSHOT_PATH + metadata + '_' + padLeft(FILECOUNT++) + '_';
}
module.exports.imgpath = imgpath;
module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH;
When I run nightwatch --config conf.js, I get this error:
Starting selenium server... started - PID: 6296
[Go] Test Suite
===================
Running: Guinea Pig Assert Title
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.8.1\', revision: \'6e95a6684b\', time: \'2017-12-01T19:05:32.194Z\'\nSystem info: host: \'S0026COW1983\', ip: \'10.39.13.81\', os.name: \'Windows Server 2008 R2\', os.arch: \'x86\', os.version: \'6.1\', java.version: \'1.8.0_131\'\nDriver info: driver.version: unknown',
error: 'session not created' },
status: 33 }
This line "webdriver.chrome.driver": "chromedriver_Win32.zip" is pointing to the zip file, you need to unzip the content and point to the exe file instead.