How to Assert or Verify Multiple Required Error message at the time on selenium webdriver
Problem Description:
I want to verify a Blank Input field Required Error message should be displayed or not. Example like that.
I have Web Element
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">First Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Last Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Phone Name is required</div>
These Error message I want to verify at the time all message assert or not.
Can you please help me how to assert all error message at the time using selenium web driver.
java selenium selenium-webdriver
add a comment |
Problem Description:
I want to verify a Blank Input field Required Error message should be displayed or not. Example like that.
I have Web Element
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">First Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Last Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Phone Name is required</div>
These Error message I want to verify at the time all message assert or not.
Can you please help me how to assert all error message at the time using selenium web driver.
java selenium selenium-webdriver
can you please explain in details i didn't get exactly what you want to do, you want to verify it on UI side on web page or directly from HTML DOM ?
– swapnil wandhe
Nov 13 at 7:30
HTML web page UI design
– Mahendra Seervi
Nov 13 at 8:34
driver.findElement(By.xpath("//div[contains(text(),'First Name is required')]")).isDisplayed(); have you tried something like this? Repeat it number of times you want it
– paul
Nov 13 at 10:02
add a comment |
Problem Description:
I want to verify a Blank Input field Required Error message should be displayed or not. Example like that.
I have Web Element
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">First Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Last Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Phone Name is required</div>
These Error message I want to verify at the time all message assert or not.
Can you please help me how to assert all error message at the time using selenium web driver.
java selenium selenium-webdriver
Problem Description:
I want to verify a Blank Input field Required Error message should be displayed or not. Example like that.
I have Web Element
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">First Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Last Name is required</div>
<div _ngcontent-c4="" class="red-text text-darken-4 fs-0--8">Phone Name is required</div>
These Error message I want to verify at the time all message assert or not.
Can you please help me how to assert all error message at the time using selenium web driver.
java selenium selenium-webdriver
java selenium selenium-webdriver
edited Nov 13 at 11:28
Md. Mokammal Hossen Farnan
585320
585320
asked Nov 13 at 7:04
Mahendra Seervi
32
32
can you please explain in details i didn't get exactly what you want to do, you want to verify it on UI side on web page or directly from HTML DOM ?
– swapnil wandhe
Nov 13 at 7:30
HTML web page UI design
– Mahendra Seervi
Nov 13 at 8:34
driver.findElement(By.xpath("//div[contains(text(),'First Name is required')]")).isDisplayed(); have you tried something like this? Repeat it number of times you want it
– paul
Nov 13 at 10:02
add a comment |
can you please explain in details i didn't get exactly what you want to do, you want to verify it on UI side on web page or directly from HTML DOM ?
– swapnil wandhe
Nov 13 at 7:30
HTML web page UI design
– Mahendra Seervi
Nov 13 at 8:34
driver.findElement(By.xpath("//div[contains(text(),'First Name is required')]")).isDisplayed(); have you tried something like this? Repeat it number of times you want it
– paul
Nov 13 at 10:02
can you please explain in details i didn't get exactly what you want to do, you want to verify it on UI side on web page or directly from HTML DOM ?
– swapnil wandhe
Nov 13 at 7:30
can you please explain in details i didn't get exactly what you want to do, you want to verify it on UI side on web page or directly from HTML DOM ?
– swapnil wandhe
Nov 13 at 7:30
HTML web page UI design
– Mahendra Seervi
Nov 13 at 8:34
HTML web page UI design
– Mahendra Seervi
Nov 13 at 8:34
driver.findElement(By.xpath("//div[contains(text(),'First Name is required')]")).isDisplayed(); have you tried something like this? Repeat it number of times you want it– paul
Nov 13 at 10:02
driver.findElement(By.xpath("//div[contains(text(),'First Name is required')]")).isDisplayed(); have you tried something like this? Repeat it number of times you want it– paul
Nov 13 at 10:02
add a comment |
2 Answers
2
active
oldest
votes
If you want to test all assert at once then you have to add softAssert in your code this will give you final results after check all the fields.
If not when assert failed happens (Assume First name error is invalid) system will throw assertion error after it.
SoftAssert softAssert = new SoftAssert();
String ActualErrorMEssage = firstNameerrorXpath.getText;
String ActualErrorMEssage2 = secondNameNameerrorXpath.getText;
softAssert.assertEquals(ActualErrorMEssage,ExpectedErrorMEssage);
softAssert.assertEquals(ActualErrorMEssage2,ExpectedErrorMEssage);
softAssert.assertAll();
add a comment |
If you can see all the error messages, when you don't enter anything into the text boxes and click on submit or register, you can get text of all this error messages and assert them.
But, if your website functionality is like let's say when you don't enter anything it shows only error for the first name field and all the other UI error's are not being shown, then you can't verify all the error messages at a time.
If all the error messages are shown at once, you can take them into a arraylist and by using Assert.assertEquals(expectedArray,actualArray), you can assert everything at once.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275562%2fhow-to-assert-or-verify-multiple-required-error-message-at-the-time-on-selenium%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to test all assert at once then you have to add softAssert in your code this will give you final results after check all the fields.
If not when assert failed happens (Assume First name error is invalid) system will throw assertion error after it.
SoftAssert softAssert = new SoftAssert();
String ActualErrorMEssage = firstNameerrorXpath.getText;
String ActualErrorMEssage2 = secondNameNameerrorXpath.getText;
softAssert.assertEquals(ActualErrorMEssage,ExpectedErrorMEssage);
softAssert.assertEquals(ActualErrorMEssage2,ExpectedErrorMEssage);
softAssert.assertAll();
add a comment |
If you want to test all assert at once then you have to add softAssert in your code this will give you final results after check all the fields.
If not when assert failed happens (Assume First name error is invalid) system will throw assertion error after it.
SoftAssert softAssert = new SoftAssert();
String ActualErrorMEssage = firstNameerrorXpath.getText;
String ActualErrorMEssage2 = secondNameNameerrorXpath.getText;
softAssert.assertEquals(ActualErrorMEssage,ExpectedErrorMEssage);
softAssert.assertEquals(ActualErrorMEssage2,ExpectedErrorMEssage);
softAssert.assertAll();
add a comment |
If you want to test all assert at once then you have to add softAssert in your code this will give you final results after check all the fields.
If not when assert failed happens (Assume First name error is invalid) system will throw assertion error after it.
SoftAssert softAssert = new SoftAssert();
String ActualErrorMEssage = firstNameerrorXpath.getText;
String ActualErrorMEssage2 = secondNameNameerrorXpath.getText;
softAssert.assertEquals(ActualErrorMEssage,ExpectedErrorMEssage);
softAssert.assertEquals(ActualErrorMEssage2,ExpectedErrorMEssage);
softAssert.assertAll();
If you want to test all assert at once then you have to add softAssert in your code this will give you final results after check all the fields.
If not when assert failed happens (Assume First name error is invalid) system will throw assertion error after it.
SoftAssert softAssert = new SoftAssert();
String ActualErrorMEssage = firstNameerrorXpath.getText;
String ActualErrorMEssage2 = secondNameNameerrorXpath.getText;
softAssert.assertEquals(ActualErrorMEssage,ExpectedErrorMEssage);
softAssert.assertEquals(ActualErrorMEssage2,ExpectedErrorMEssage);
softAssert.assertAll();
answered Nov 13 at 10:04
SDK_90
214
214
add a comment |
add a comment |
If you can see all the error messages, when you don't enter anything into the text boxes and click on submit or register, you can get text of all this error messages and assert them.
But, if your website functionality is like let's say when you don't enter anything it shows only error for the first name field and all the other UI error's are not being shown, then you can't verify all the error messages at a time.
If all the error messages are shown at once, you can take them into a arraylist and by using Assert.assertEquals(expectedArray,actualArray), you can assert everything at once.
add a comment |
If you can see all the error messages, when you don't enter anything into the text boxes and click on submit or register, you can get text of all this error messages and assert them.
But, if your website functionality is like let's say when you don't enter anything it shows only error for the first name field and all the other UI error's are not being shown, then you can't verify all the error messages at a time.
If all the error messages are shown at once, you can take them into a arraylist and by using Assert.assertEquals(expectedArray,actualArray), you can assert everything at once.
add a comment |
If you can see all the error messages, when you don't enter anything into the text boxes and click on submit or register, you can get text of all this error messages and assert them.
But, if your website functionality is like let's say when you don't enter anything it shows only error for the first name field and all the other UI error's are not being shown, then you can't verify all the error messages at a time.
If all the error messages are shown at once, you can take them into a arraylist and by using Assert.assertEquals(expectedArray,actualArray), you can assert everything at once.
If you can see all the error messages, when you don't enter anything into the text boxes and click on submit or register, you can get text of all this error messages and assert them.
But, if your website functionality is like let's say when you don't enter anything it shows only error for the first name field and all the other UI error's are not being shown, then you can't verify all the error messages at a time.
If all the error messages are shown at once, you can take them into a arraylist and by using Assert.assertEquals(expectedArray,actualArray), you can assert everything at once.
answered Nov 13 at 9:04
Kaushik
518
518
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275562%2fhow-to-assert-or-verify-multiple-required-error-message-at-the-time-on-selenium%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can you please explain in details i didn't get exactly what you want to do, you want to verify it on UI side on web page or directly from HTML DOM ?
– swapnil wandhe
Nov 13 at 7:30
HTML web page UI design
– Mahendra Seervi
Nov 13 at 8:34
driver.findElement(By.xpath("//div[contains(text(),'First Name is required')]")).isDisplayed(); have you tried something like this? Repeat it number of times you want it– paul
Nov 13 at 10:02