In Cypress how to extract the error message? - cypress

Automating cypress. Attaching the screenshot. How can I extract the error message "Password must be greater than 8 characters"? Input is greatly appreciated.
Some additional info, when I inspect the HTML following is what I see.
How can I grab the text "Password must be greater than 8 characters"

It is not in the the HTML of the page, it is a property of the element that is displayed directly by the browser.
To access it, you will use HTMLObjectElement.validationMessage.
Your test will be something like this code:
cy.get('#password').its('validationMessage').should('contain', 'Password must be greater than 8 characters')

Related

Getting this message app.js:33 Uncaught TypeError: Cannot read property 'appendChild' of null at HTMLButtonElement.addTodo

enter image description here
enter image description here
I had to initially put the behind the body because it was refreshing the page.
Now i'm running into this error "app.js:33 Uncaught TypeError: Cannot read property 'appendChild' of null
at HTMLButtonElement.addTodo"
Your selector is .todo-List, yet all your other class names don't use any upper-case characters, and your HTML shows class="todo-list" (list, not List!) as well.
So, I'd assume that this is a typo and should actually be todo-list with lower-case l, so you should change the line 4 to const todoList = document.querySelector('.todo-list').
The fact that you asked about the "message" of Cannot read property "appendChild" of null though sounds to me as if you didn't understand the error message. Please take the time to review this article and take a quick squiz at how to use a debugger. Especially the latter is a tremendously important skill that will help you trace back those issues yourself. I'm sure, had you realized that the issues comes from line 4, you'd eventually have discovered that the selector is wrong.

Nightwatch error message

Can I change text output of failed tests in Nightwatch.js?
× Password Input in "Log in" Pop-up (#password) visible for 16000ms - expected "visible" but got: "not found"
I expect:
× Password Input in "Log in" Pop-up (#password) NOT FOUND for 16000ms
It depends on what you are using. If you are using any of the expect commands then no, you cannot customize the message. However, if you are using assert then you can.
browser.assert.visible('.should_be_visible', 'This is my custom message');
Old question but the above answer is not strictly correct. While some expect commands do not support an optional message, there are also those that do. You can look through the api docs which will tell you which commands support messages and which do not here: http://nightwatchjs.org/api
What is important to note is that optional messages as shown in the answer above will output regardless of pass/fail, meaning they are not strictly 'error messages'.
One way to adapt this is through your naming, for example if a test is looking for an element on a page, do not use a message of 'Cannot find element' as this will display even if the element is found successfully. Instead use something like 'Looking for element'...
.waitForElementVisible('#element', 1000, 'Looking for something on some page')
This at least tells the user what the test was trying to do when it failed but also makes sense when it passes. Hope that helps.

Validate SharePoint Text Box to Limit Number of Words

I am trying to use validation for the text bos on the SharePoint Add New form to limit number of words entered into the field. Unfortunately solution I have found on stack overflow does not work for me. I have entered
string-length(Status) - string-length(translate(Status, " ", "")) < 10
into validation rule, Status is the name of the text field I want to limit / validate. When I run rule inspector it is showing Invalid Field in red in the Validation area. The rule is not working, is displaying red warning, does not matter what I enter into the field and I cannot save entered data.. What I am doing wrong? What I have to do to have it working ???
Thanks for help.
I have received correct answer Microsoft Developers Network from Sathiya Kamalanathan. The valication which works is:
string-length(.) - string-length(translate(., " ", "")) > 10
I hope it will help others to solve similar problems.

How to limit the characters in input field in crystal report

I am using crystal report 2008, i have a report and that has a input field called "Departure_no".
In this input field we can type maximum of four departure_no (Eg: 2345,234,2345,23456), if it exceeds this limit(more than 4 numbers-can count with 3 commas(,)), this input field should not allow to type further.
Is there any way to achieve this by formula or something else by crystal report??
Thanks in advance!!
Priya
try below
use alerts to show the message: I am showing on a database field
Go to Report--> Alert --> Create or modify alert
When a window is opened provide the following:
required name
Required message
Condtion when alert need to be displayed
You can give condition as
if Length(databasefield)> 4 //you need only 4 chars hence this condition
then true
else false
Click ok.
Now you will get message
Let me know of you are looking for something different

JMeter issues with span tag in Response Assertion

I added a Response Assertion to my test to hit the home page of our local site. I added this to the "Patterns to Test" in a Response Assertion:
Email
This worked. ( To get that label, I did View Source in Firefox and copied the code including all white space. I then clicked "Add" for the Response Assertion and pasted the copied code directly into JMeter this way. ) When I run my test, my test will pass with just this label as a Pattern to Test. It shows no red errors after running it in JMeter.
However, when I add the following span tag by clicking on "Add" to get a new entry in the same Response Assertion, the test will fail.
1.7.0.147
So, to be clear, I had 2 entries for the same Response Assertion...one for the "Email" label and one for the "footerVer" span. Each of these had their own separate line under the same Response Assertion.
Also, for most tests that passed and did not pass, I had "Main Sample only", "Text Response", and "Contains" selected. I did try to change to "Matches" and "Equals" but I just ended up with different errors. So, I wanted to stay on "Contains" for now since my other entry for the "Email" label worked when I had "Contains" selected.
Under the "View Results Tree", JMeter tells me about this failure when I add the span tag:
Assertion error: false
Assertion failure: true
Assertion failure message: Test failed: text expected to contain /
1.7.0.147
/
I also have had success with other tags like , , , , etc. along the way.
Only the tag seems to be giving me a problem right now. Any ideas?
===============================
Added config:
I am not able to add the full response since it is not my code, but the company's code. But, I can try to get something on here that me be useful in a different way.
This is the response dealing with the version copied verbatim from the response tab within JMeter:
<span class="footerVer">
1.7.0.147
</span>
Hope that helps
I would suggest using XPath assertions for multiline HTML entities parsing as page source may vary and it can be a headache to deal with flaky HTML code.
Following XPath expression validates whether inner text of span with footerVer class equals 1.7.0.147
//span[#class='footerVer']/text()='1.7.0.147'
Use Substring instead of Contains for Pattern Matching rules:
http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion
So, I found one way around this. Although, I do not think this is the most efficient way to verify the test. I split the span into 3 individual lines in the Response Assertion.
<span class="copyright marginLeft_100">
© Copyright 2002-2013 Turning Technologies, LLC. All Rights Reserved.
</span>
==========================
I do not really mind the first 2 lines. But, the third line is so generic it really does no good if not combined with the beginning tag
Well, for now, I can at least confirm something. Also, I left it on "Contains", even though I took a look at the other link posted above, because all of my other tags presented no problem when it was on "Contains". Hope this helps someone else also.

Resources