Getting error with Toaster form using cypress end 2 end - cypress

I am new in the use of cypress, which makes me face concern.
I would like to automate actions in order to test some Progressive Web App (PWA) and so I have recorded actions using the cypress extension of google chrome and when I create specs in cypress locally in order to reproduce the captures, I get errors especially when I am facing toasters.
cy.get('.h-full > #app > .layout--full > div > .hover\\3Aopacity-90').click()
cy.get('#app > .layout > .my-10 > .list-item:nth-child(3) > .text').click()
**cy.get('.h-full > #app > .pt-4 > .transform > .svg-inline--fa').click()**
cy.wait(15000)
cy.get('.form > .flex > div > .mt-6 > #mark').click()
cy.get('.form > .flex > div > .mt-6 > #mark').select('other')
The toaster pops up and then I get this error.
I even added a wait but without success

Related

Cypress file upload

I have a "problem"
I'm trying to upload a file in my cypress test, however my test runs with sucess but it doesn't upload.
I using the library cypress-file-upload;
my code:
const filePath = 'teste.pdf'
cy.get(':nth-child(1) > .backgroundColor > :nth-child(2) > :nth-child(1) > .col-auto > .input-group.mb-0 > .custom-file > .row > .form-group > .input-group > .input-group-text').attachFile(filePath)
result:
enter image description here
my html/css:
enter image description here
button:
enter image description here
ps: sorry for my bad english
I'm trying many css selector until xpath, but doesn't sucess
I think your target element in this case should be the input one.
Make sure teste.pdf is located at fixtures folder and try something like:
const filePath = 'teste.pdf'
cy.get('.custom-file-input.form-control-sm.file-input').attachFile(filePath)

How to test if an alert message is showing what I wanted it to show using Cypress?

I have password reset page I'd like to perform some tests on. If my current password won't match with my typed current password area it shows a "Password don't match" alert. Here is my alert:
<p-message *ngIf="error" severity="error" id="alert-danger" class="alert alert-danger" text="{{'password.messages.error' | translate}}" >
<ng-template pTemplate>
<div jhiTranslate="password.messages.error" ></div>
</ng-template>
</p-message>
What I've tried so far:
cy.get('[severity="error"] > .p-inline-message > .p-inline-message-text')
.should("have.text","password.messages.error")
But I get an error in cypress saying "expected password.messages.error but the text was Passwords don't match!. Which is understandable it takes directly whatever text was inside my element. Then I've tried:
cy.get('[severity="error"] > .p-inline-message > .p-inline-message-text')
.invoke('attr','jhiTranslate')
.should('eq','password.messages.error')
this gives me "expected undefined to equal password.messages.error"
What I'm doing wrong and what else should I try here?
Just change the text Cypress is checking,
cy.get('[severity="error"] > .p-inline-message > .p-inline-message-text')
.should("have.text", "Passwords don't match!")
The HTML you show above is the source code, but AngularJS has looked up the variable password.messages.error and output the string contained in that variable.
It then removes jhiTranslate from the element, so you cannot test it at runtime (in the browser).
You can see what the runtime HTML is by right-clicking on an element and inspecting it in the dev-tools.
You can do something like:
cy.get('p-message#alert-danger').within(() => {
cy.get('div').should('have.attr', 'jhiTranslate', 'password.messages.error')
})

java.lang.NoSuchMethodError: No such DSL method 'warnings' found among steps

We are migrating the jobs from older jenkins environment (version 2.48) to new jenkins environment (2.263), job execution with "jenkinsFile" failed with this below exception, and below is the detail of the jenkinsFile, "basic pipeline" plugin was already installed inthe jenkins yet, its failing. Any solution is appreciated.
#!groovy
pipeline {
agent { label 'acme-label' }
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
timestamps()
}
stages {
stage("Checkout") {
steps {
checkout scm
}
}
stage("Install Dependencies") {
steps {
sh "bundle install --deployment"
}
}
stage("Lint") {
steps {
sh "bundle exec rake"
}
}
}
post {
always {
warnings canRunOnFailed: true, consoleParsers: [[parserName: 'Foodcritic']]
}
failure {
script {
mailer.send('acme')
}
}
}
}
> 11:49:33 java.lang.NoSuchMethodError: No such DSL method 'warnings'
> found among steps [addEmbeddableBadgeConfiguration, ansiColor,
> archive, bat, build, catchError, checkout, checkpoint,
> compareVersions, container, containerLog, copyRemoteArtifacts,
> deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo,
> emailext, emailextrecipients, envVarsForTool, error, fileExists,
> findFiles, getContext, git, httpRequest, input, isUnix, jiraComment,
> jiraIssueSelector, jiraSearch, junit, library, libraryResource, load,
> mail, milestone, node, nodesByLabel, parallel, podTemplate,
> powershell, properties, publishChecks, publishEvent, publishHTML,
> publishIssues, pwd, pwsh, readCSV, readFile, readJSON, readManifest,
> readMavenPom, readProperties, readTrusted, readYaml, recordIssues,
> resolveScm, retry, sauce, sauceconnect, scanForIssues, script, sh,
> sha1, sleep, stage, stash, step, tee, throttle, timeout, timestamps,
> tm, tool, touch, triggerRemoteJob, unarchive, unstable, unstash,
> unzip, validateDeclarativePipeline, waitForQualityGate, waitUntil,
> warnError, withContext, withCredentials, withDockerContainer,
> withDockerRegistry, withDockerServer, withEnv, withMaven, wrap,
> writeCSV, writeFile, writeJSON, writeMavenPom, writeYaml, ws, xunit,
> zip] or symbols [AUnit, BoostTest, CTest, CUnit, Check, CppTest,
> CppUnit, Custom, FPCUnit, GoogleTest, JUnit, MSTest, MbUnit, NUnit2,
> NUnit3, PHPUnit, PVSStudio, QtTest, UnitTest, Valgrind,
> abstractItemDirectoryComponent, acuCobol,
> agentDumpExportTableComponent, agentJVMProcessSystemMetricsComponent,
> agentSystemConfigurationComponent, agentsConfigFileComponent, ajc,
> all, allBranchesSame, allOf, always, androidLintParser,
> anonymizeSupportBundle, ansibleLint, ant, antFromApache, antOutcome,
> antPath, antTarget, any, anyOf, apiToken, architecture,
> archiveArtifacts, armCc, artifactManager, artifactsPublisher,
> authorizationMatrix, aws, awsCredentials, axivion, axivionSuite,
> batchFile, bitbucket, bitbucketBranchDiscovery,
> bitbucketForkDiscovery, bitbucketPublicRepoPullRequestFilter,
> bitbucketPullRequestDiscovery, bitbucketSshCheckout,
> bitbucketTagDiscovery, bitbucketTrustEveryone, bitbucketTrustNobody,
> bitbucketTrustProject, bitbucketTrustTeam,
> bitbucketWebhookConfiguration, bitbucketWebhookRegistration,
> blindlyTrust, booleanParam, branch, brokenBuildSuspects,
> brokenTestsSuspects, buckminster, buildAllBranches, buildAnyBranches,
> buildButton, buildChangeRequests, buildDescription, buildDiscarder,
> buildDiscarders, buildFailureAnalyzer, buildName, buildNamedBranches,
> buildNoneBranches, buildRegularBranches, buildRetention, buildTags,
> buildingTag, cadence, cargo, caseInsensitive, caseSensitive, ccm,
> certificate, changeRequest, changelog, changeset, checkStyle,
> checkoutToSubdirectory, choice, choiceParam, clair, clang,
> clangAnalyzer, clangTidy, cleanWs, clock,
> cloudBeesPipelineTemplatesFolder, cloudBeesRoleBasedAccessControl,
> cmake, cobertura, coberturaAdapter, codeAnalysis, codeNarc, command,
> concordionPublisher, configFile, configFileProvider, configMapVolume,
> containerEnvVar, containerLivenessProbe, containerTemplate, coolflux,
> cpd, cppCheck, cppLint, credentials, cron, crumb, cssLint, cssText,
> cssUrl, culprits, customProbe, default, defaultFolderConfiguration,
> defaultView, demand, dependenciesFingerprintPublisher, detekt,
> developers, diabC, disableConcurrentBuilds, disableResume, docFx,
> docker, dockerCert, dockerLint, dockerServer, dockerTool, dockerfile,
> downstream, doxygen, drMemory, dscanner, dumb, dupFinder,
> durabilityHint, dynamicPVC, eclipse, embUnit, emptyDirVolume,
> emptyDirWorkspaceVolume, envInject, envVar, envVars, envVarsFilter,
> environment, equals, erlc, errorProne, esLint, eventTrigger, exact,
> excludeCategory, excludeFile, excludeMessage, excludeModule,
> excludeNamespace, excludePackage, excludeType, expression, failed,
> faviconUrl, file, fileParam, filePath, findBugs, findbugs,
> findbugsPublisher, fingerprint, fingerprints, flake8, flawfinder,
> flexSdk, frameOptions, freeStyle, freeStyleJob, fromDocker, fromScm,
> fromSource, fromTemplateFactory, fxcop, gcc, gcc3, gcc4, gendarme,
> ghsMulti, git, gitBranchDiscovery, gitHubBranchDiscovery,
> gitHubBranchHeadAuthority, gitHubExcludeArchivedRepositories,
> gitHubExcludePublicRepositories, gitHubForkDiscovery,
> gitHubPullRequestDiscovery, gitHubSshCheckout, gitHubTagDiscovery,
> gitHubTopicsFilter, gitHubTrustContributors, gitHubTrustEveryone,
> gitHubTrustNobody, gitHubTrustPermissions, gitTagDiscovery, github,
> githubPush, globalConfigFiles, gnat, gnuFortran, goLint, goVet,
> groovyScript, gtester, hadoLint, headRegexFilter, headWildcardFilter,
> hostPathVolume, hostPathWorkspaceVolume, hyperlink, hyperlinkToModels,
> iar, iarCstat, ibLinter, ideaInspection, includeCategory, includeFile,
> includeMessage, includeModule, includeNamespace, includePackage,
> includeType, infer, inheriting, inheritingGlobal, installSource,
> intel, invalids, invokerPublisher, isRestartedRun, issues,
> istanbulCobertura, istanbulCoberturaAdapter, jacoco, jacocoAdapter,
> jacocoPublisher, java, javaDoc, javadoc, jcReport, jclouds, jdk,
> jdkInstaller, jgit, jgitapache, jgivenPublisher, jmespathQuery, jnlp,
> jobBuildDiscarder, jobDsl, jobName, jsHint, jsLint, jsUrl, jsonEvent,
> junitParser, junitPublisher, junitTestResultStorage, klocWork,
> knownHosts, kotlin, ktLint, kubeconfig, kubernetes,
> kubernetesPodTemplates, label, lastDuration, lastFailure,
> lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM,
> list, local, location, logRotator, loggedInUsersCanDoAnything, mailer,
> manualLaunchOnly, manually, masterBuild,
> masterJVMProcessSystemMetricsComponent,
> masterSystemConfigurationComponent, maven, maven3Mojos, mavenConsole,
> mavenErrors, mavenLinkerPublisher, mavenMojos, mavenWarnings, merge,
> metrowerksCodeWarrior, mineRepository, modelsim, modernSCM, msBuild,
> myPy, myView, nagFortran, namedBranchesDifferent, never,
> newContainerPerStage, nfsVolume, nfsWorkspaceVolume, nioSsh, node,
> nodeProperties, nodeRemoteDirectoryComponent, nonInheriting, none,
> not, onFailure, openTasks, openTasksPublisher, override,
> overrideIndexTriggers, owners, paneStatus, parallelsAlwaysFailFast,
> parameters, passed, password, pattern, pcLint, pep8, perforce,
> perlCritic, permanent, persistentVolumeClaim,
> persistentVolumeClaimWorkspaceVolume, php, phpCodeSniffer, phpStan,
> pipeline-model, pipeline-model-docker, pipelineGraphPublisher,
> pipelineMaven, pipelineTriggers, pit, plainText, plugin, pmdParser,
> podAnnotation, podEnvVar, podLabel, pollSCM, portMapping, prefast,
> preserveStashes, projectNamingStrategy, protoLint, proxy, pruneTags,
> publishCoverage, publishEvent, puppetLint, pyDocStyle, pyLint,
> qacSourceCodeAnalyser, queueItemAuthenticator, quietPeriod, rateLimit,
> rateLimitBuilds, recipients, recordIssues, regex, requestor,
> resharperInspectCode, resourceRoot, retainOnlyVariables, rfLint,
> robocopy, ruboCop, run, runDirectoryComponent, runParam, s3,
> saucePublisher, scala, schedule, scmRetryCount, script,
> scriptApproval, scriptApprovalLink, search, secretEnvVar,
> secretVolume, security, shell, simian, simple-theme-plugin,
> simpleBuildDiscarder, simpleEvent, simpleMatch, skipDefaultCheckout,
> skipStagesAfterUnstable, skipped, slave, snapshotDependencies,
> sonarQube, sourceFiles, sourceRegexFilter, sourceWildcardFilter,
> sphinxBuild, spotBugs, spotbugsPublisher, sshPublicKey,
> sshUserPrivateKey, standard, status, string, stringParam, styleCop,
> sunC, suppressAutomaticTriggering, swapSpace, swiftLint, tag, tagList,
> taskScanner, taskingVx, teamSlugFilter, text, textParam,
> threadDumpsComponent, throttleJobProperty, tiCss, timestamper,
> timestamperConfig, timezone, tmpSpace, tnsdl, toolLocation,
> triggeredBy, trustInitial, tsLint, unsecured, untrusted, upstream,
> upstreamDevelopers, url, usageStatisticsCloudBees, userSeed,
> usernameColonPassword, usernamePassword, viewsTabBar, warningsParsers,
> warningsPlugin, weather, wildcards, withAnt, withAwsCli,
> withSonarQubeEnv, x509ClientCert, xUnitDotNet, xlc, xmlLint, yamlLint,
> yuiCompressor, zfs, zip, zptLint] or globals [btools, currentBuild,
> currentJob, docker, duration, env, generateTestGroup, jenkins, log,
> mailer, mavenBuild, params, pipeline, runTestGroup, scm, shell, slack]
> 11:49:33 at
> org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:202)
> 11:49:33 at
> org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
> 11:49:33 at sun.reflect.GeneratedMethodAccessor1136.invoke(Unknown
> Source) 11:49:33 at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 11:49:33 at java.lang.reflect.Method.invoke(Method.java:498)
> 11:49:33 at
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
> 11:49:33 at
> groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)

Multiple #EnsuresNonNullIf should be ok; but the compiler complains

The manual of the Checker Framework claims "You can write multiple #EnsuresNonNullIf annotations on a single method", however I observe the following message if I try this:
#EnsuresNonNullIf(expression="getFieldNames()", result=true)
#EnsuresNonNullIf(expression="getFieldName(i)", result=true)
public boolean hasFieldNames() {
return fFieldNames != null;
}
The resulting error message by the Eclipse Java compiler:
Duplicate annotation of non-repeatable type #EnsuresNonNullIf. Only annotation types marked #Repeatable can be used multiple times at one target.
The resulting error message by the MVN javac compiler:
[ERROR] Blabla.java:[?,?] org.checkerframework.checker.nullness.qual.EnsuresNonNullIf is not a repeatable annotation type
I'm annotating 10-year-old code, so I'm hoping some configuration trick can safe the day :-) Without the multiple #EnsuresNonNullIf I'm up for quite a bit of manual code annotation to fix false positives that I'm not interested in...
PS: I tried using both checker-framework-2.8.1 and 2.9.0 with similar results, and always using <maven.compiler.source>1.8</maven.compiler.source>
I found this issue on the Checker Framework issue tracker: https://github.com/typetools/checker-framework/issues/1307
It explains an "enhancement" request for adding #Repeatable to the following CF annotations:
> #DefaultQualifier -- DONE
> #EnsuresKeyFor
> #EnsuresKeyForIf
> #EnsuresLockHeldIf
> #EnsuresLTLengthOf
> #EnsuresLTLengthOfIf
> #EnsuresMinLenIf
> #EnsuresNonNullIf
> #EnsuresQualifier -- DONE
> #EnsuresQualifierIf -- DONE
> #FieldInvariant
> #GuardSatisfied
> #HasSubsequence
> #MethodVal
> #MinLenFieldInvariant
> #RequiresQualifier -- DONE
> #SubstringIndexFor
And the discussion contains a workaround, since EnsuresQualifiersIf is already repeatable:
#EnsuresQualifiersIf({
#EnsuresQualifierIf(result=true, qualifier=NonNull.class, expression="getFoo()"),
#EnsuresQualifierIf(result=false, qualifier=NonNull.class, expression="getBar()")
})
boolean hasFoo();
And in my case that works out to:
#EnsuresQualifiersIf({
#EnsuresQualifierIf(result=true, qualifier=NonNull.class, expression="getFieldNames()"),
#EnsuresQualifierIf(result=true, qualifier=NonNull.class, expression="getFieldName(i)")
})
public boolean hasFieldNames() {
return fFieldNames != null;
}

Which selenium command can I use to assert an element is not present

I'm writing a script in which i will verify if some elements are present and others are not.
For the ones which are present I'm using:
verify do
assert_include(
#driver.find_element(
:css,
"div.launchpadMain > section:nth-of-type(4) > div.launchpadCategoryBody > a:nth-of-type(2)"
).text,
"shiftplan"
)
end
Example for a element which is not present... I'm trying:
verify do
element_not_present(
#driver.find_element(:css, "button.btn.btn-icon.pull-right > i")
)
end
---> This is not working though. Which command can I use to make a verification if the element/object is present or not? In this case the element/object is a trash icon.
Switch to the group collector find_elements (plural), to stop it returning an exception, then assert it's empty.
verify do
assert_empty(
#driver.find_elements(:css, "button.btn.btn-icon.pull-right > i").size
)
end
find_elements: http://www.rubydoc.info/gems/selenium-webdriver/0.0.28/Selenium%2FWebDriver%2FFind:find_elements

Resources