Questions tagged [assert]

An assertion is a statement, which aborts a program when it evaluates to false. Assert is typically used for debugging and situations which should never happen.

Filter by
Sorted by
Tagged with
6 votes
1 answer
26k views

How do I verify a Link URL using Selenium Webdriver / TestNG?

I'm trying to do an assert to make sure a correct XMLHttpRequest is made. I know that I can get the exact Request URL from the Developers Console -> Network tab -> XHR tab's general information ...
Tscott's user avatar
  • 173
5 votes
5 answers
34k views

Is there any way to continue selenium web driver script after assert fails?

I have some script which is written with selenium webdriver. Actually, I have put some assert statement in between script. When an assert statement fails my script stops execution. Is there any way ...
Sagar007's user avatar
  • 1,330
5 votes
8 answers
87k views

How to verify a success message using selenium webdriver?

I am unable to verify this sucess message. I am trying to use the following code: 1. String expectedText ="Dear admin, the Institution is deleted successfully!"; Assert.assertEquals("...
Imtiaz Ahmed Biplob's user avatar
4 votes
2 answers
802 views

How to add an assert to an if ..else condition using Phpunit and selenium webdriver

I'm working on test automation for a big project and I'm using Phpunit and as a server I'm using Selenium WebDriver. In the source code I'm using asserts like : $this->assertContains('Project Title'...
Baini.Marouane's user avatar
3 votes
1 answer
6k views

Exception in thread "main" java.lang.AssertionError: expected [3] but found [3]

System.setProperty("webdriver.chrome.driver", "C:\\Users\\srajendran\\Documents\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); driver.get("http://qaclickacademy.com/practice.php"); ...
Kumar Raj's user avatar
3 votes
4 answers
9k views

Assertion message with TestNG

I use TestNG for assertion, for example with this assertTrue: Assert.assertTrue(boolean b, String s) If the assert is failed, then the String s will be printed out, and if assertion is passed, then ...
Ragnarsson's user avatar
3 votes
1 answer
5k views

Efficient way to test data quality of database through java?

I currently have to test the data that is being processed from a file into the database. Currently I'm using Java to extract the data from the database and compare the data mapped to the table ...
Nabz's user avatar
  • 132
3 votes
2 answers
1k views

Unable to open an .xlsx file with script in Selenium WebDriver - getting InvalidFormatException

I have a script that requires an excel spreadsheet to be downloaded from a website and opened, ending in an assertion that a certain value exists or not on the spreadsheet. Getting the following ...
hungryhippos's user avatar
2 votes
2 answers
2k views

How to verify data is saved or not using selenium?

I am using selenium and java for automation. I am adding new data. after a click on save, data will appear on the left side on the top list and I want to verify. I want to get the first text "new aam ...
Aam ali's user avatar
  • 137
2 votes
3 answers
24k views

How to print a message after checking through TestNG's Assert.assertEquals method?

I'm getting a string value from a function. Now I want to print a message saying whether expected string and actual string are different or not. To compare these string I'm using TestNG's Assert....
Syrus's user avatar
  • 1,197
2 votes
4 answers
7k views

Assert in TestNG (Actual int value, Expected int value)

Is there anyway to assert that, actual int value = expected int value not equal to 0 Something like, Assert.assertEquals(length, 0);
ilm's user avatar
  • 386
2 votes
2 answers
601 views

JUnit Assert's message equivalent implementation using Selenium Webdriver's wait method

In JUnit's assertions you have an optional parameter which allows you to to display it when the assertion fails, to allow the tester know what actually failed from a human-friendly perspective. Is ...
gvasquez's user avatar
  • 269
2 votes
2 answers
213 views

Is it necessary to Assert web page title in every case?

I am writing a script in Selenium and TestNG to automate Add User profile pages. Now, when I land on every new page, then do I need to write Assert.equals("add user profile", driver.gettitle(...
Nitin67's user avatar
  • 31
2 votes
2 answers
651 views

How to assert checkbox is marked using JavaScript

I’ve problem to assert that checkbox is checked. I’m using automation web testing framework which recording my clicks and generate JavaScript code. The problem is even if the checkbox is unmarked, ...
locke's user avatar
  • 65
2 votes
1 answer
14k views

How to write Assertion in Selenium Cucumber BDD?

I want to use assertion in cucumber to verify my test output, can some please write me an example how to do the same in cucumber. As I googled, I found that people use junit/TestNG assertions like ...
Rose's user avatar
  • 101
2 votes
1 answer
480 views

Assertion about size of an XML tag

Community, I'm trying to add an assertion for an XML Response that verifies the size of the info of one of the tags. So for example, this is my response: <description>This is your password</...
Nana89's user avatar
  • 163
2 votes
1 answer
709 views

how to enable assertions through the Gradle Kotlin DSL?

The simplest possible assert usage I could think of: thufir@dur:~/NetBeansProjects/helloAssertions/src/main/java$ thufir@dur:~/NetBeansProjects/helloAssertions/src/main/java$ ls App.java thufir@dur:~...
Thufir's user avatar
  • 367
2 votes
1 answer
354 views

Unresolved reference: enableAssertions

working assertions example using standard Java SE with no imports: thufir@dur:~/jshell$ thufir@dur:~/jshell$ javac App.java thufir@dur:~/jshell$ thufir@dur:~/jshell$ java -ea App Exception in ...
Thufir's user avatar
  • 367
2 votes
3 answers
427 views

How to verify the body context using Assert command [closed]

I want to pass my test.When I run my test it gets fail because expected and actual is not matching. How to do with assert command? When I copy the actual value it shows like an error: {"level":"...
user avatar
2 votes
2 answers
3k views

AND/OR Operation in Contains Assertion in SOAP UI

There's one tag in my XML response whose elements (JSON Data) always come in different order. Is there any way to create a contains assertion with AND/OR operations or should I just use a Script ...
Nana89's user avatar
  • 163
2 votes
1 answer
319 views

How to assert custom XML response does not return any unwanted tags in SOAPUI?

I wonder if there is a way to assert that XML response does NOT contain any other tags than those expected? I am using plain http requests (no WSDL, schema validation, not SOAP, not REST) and the ...
LadyRoot's user avatar
2 votes
1 answer
1k views

Selenium: Isolating Assert Fail in Excel Data Driven Loop

Firstly I would like to point out that I'm a beginner when it comes to selenium so I apologise if this is not presented appropriately. I would like to incorporate data driven testing into my ...
AndyQANoob's user avatar
1 vote
1 answer
5k views

[Selenium]getAttribute using "textContent" - assertion fails when 'equals' is used but works when 'contains' is used

Here is the sample: WebElement LoginLabel = driver.findElement(location); assert LoginLabel.getAttribute("textContent").equals("Login ID"); Above code fails while asserting but when I try to print ...
Whereismymind's user avatar
1 vote
3 answers
688 views

Selenium IDE assertion, text in commented body tag

I am trying to run a test in Selenium IDE, and at the end of the test it looks for the DOM element that is commented out this looks like: </div><!-- QID: Q1447180888OFH--></body><...
DEnumber50's user avatar
  • 1,190
1 vote
3 answers
311 views

What elements should I assert for automation of my eCommerce application? [closed]

What are useful and practical asserts to consider in our web automation project which uses selenium (java) to automate an eCommerce web application. As this is my first website to automate, I am ...
Camreyjones's user avatar
1 vote
2 answers
3k views

TestNG + java. Difference between Assert.assertTrue and Assertion?

I'm a little bit confused in testNG assertion methods. My question is simple - is there any difference between Assert.assertTrue and Assertion? I mean difference between following: Assert.assertTrue(...
Pasha's user avatar
  • 63
1 vote
3 answers
1k views

When should we use Assert.true() instead of Assert.equals() method in Selenium?

What's the difference between these 2 Assert class methods?
Tester68's user avatar
1 vote
1 answer
1k views

How to compare big objects with FluentAssertsions?

I am doing integrative xunit tests on a .NET Core web application. The result of a call can sometimes be a large object with different levels of hierarchy. MainEntity { public ...
Claudiu A's user avatar
  • 209
1 vote
1 answer
167 views

NUnit Assert.This(obj, method) for C# - where to find list of evaluation methods?

I'm an old embedded coder, new to NUnit and VS C#. I'm trying to get used to the Assert.That(obj,[EvaluationMethod]) methodology that NUnit 3.x is promoting. I'm slowly getting up to speed, but was ...
kking85743's user avatar
1 vote
2 answers
217 views

Playwright: expect.toHaveAttribute: Unsupported token "@xpath" while parsing selector

In Playwright I created a script to verify the title using toHaveAttribute assertion for this element: <title style="" xpath="1">Unient | Your Versatile Partner for Better ...
Sarah G's user avatar
  • 11
1 vote
1 answer
787 views

Compare 2 JDBC response in Jmeter

I want to compare 2 JDBC responses: I have Source reponse from 1 JDBC request as below in table format: (Source DB)JDBC Response response1: (Target DB)JDBC Reponse 2: I am saving the response as ...
Mayank Parekh's user avatar
1 vote
0 answers
125 views

Testing if the Editfield is editable using LeanFt

We have an editfield that is detected as a Winforms editfield in the object identification center of LeanFt when it is spied upon. Whether it is editable or not depends on some pre-conditions. ...
pradeep srinivasan's user avatar
1 vote
1 answer
1k views

Difference between Hamcrest-library jar and Hamcrest-all jar

What is the difference between using the hamcrest-library-1.3.jar that comes bundled with Selenium Webdriver (I use v2.49) and hamcrest-all-1.3.jar found on the official website of Hamcrest https://...
ilm's user avatar
  • 386
0 votes
3 answers
124 views

Assertion on static value or calculated one

This may be more of a theoretical question than a practical one, but I'd like to know the community's opinion. Some context: On some integration UI test, in which we are testing that a field ...
ggonmar's user avatar
  • 103
0 votes
2 answers
764 views

How to use assertion to compare both different size of the rows?

I want both size of the rows shouldn't be matched. int firstnum = 0; List<WebElement> preRoutlList = driver.findElements(By.xpath("//*[@id='txBottomTable']/table/tbody/tr")); ...
Samira's user avatar
  • 23
0 votes
3 answers
6k views

How to test forgot password link?

I want to automate forgot password link. When click on forgot password link It goes to enter the email A link would be send via email. When click on that link we can get the change psssword option. ...
user avatar
0 votes
2 answers
706 views

How to solve AssertionError in Selenium Python?

I am currently working on a project in Selenium in Python and I am getting AssertionError when I put a specific parametrised value 6.00 in the parentheses. Test.py Class Test: def test_voidnewcard(...
TechGeek49's user avatar
0 votes
1 answer
2k views

Is it possible to display the assertion results in the View Results Tree listener itself in Jmeter?

Is there anyway we can display the assertion results in the View Results Tree listener itself? Also, the Assertion Results listener displays only failed assertions, is there a simple way to display ...
Rohan Kalia's user avatar
0 votes
1 answer
1k views

What is the use of waitForPageLoad() method in Framework when our test scripts don't execute unless the page is loaded by default

public void waitForPageLoad(WebDriver driver){ while(true){ String page_status =(String)((JavascriptExecutor)driver).executeScript("return document.readyState"); if(page_status....
Ram Patro's user avatar
0 votes
1 answer
2k views

Assertion error when comparing the text of an element

I am getting the following error while trying to verify an assertion. I tried adding wait, but it didn't help. Error message: java.lang.AssertionError: expected:<Risk Assessment Form: Completed&...
Meenakshi's user avatar
0 votes
0 answers
253 views

How to verify the Json response field data type in rest assured test

How can we verify the Json data type of mentioned fields such as "price", "ck", "name", "enabled" and "tags" in rest assured test. { "odd":...
swapnil shirke's user avatar
0 votes
1 answer
51 views

How to assert whether the file has been uploaded or not?

<div class="form-fill-file"> <input data-val="true" data-val-requiredif="Please upload invoice file." id="Upload_File" name="Upload.File" ...
Aishwarya's user avatar
0 votes
1 answer
241 views

Can I keep the Groovy power assert and still have a custom message printed?

I use Katalon Studio for my test automation. It comes with an in-built script editor (Groovy). So, I can use Groovy's power assert that gives me a nice and detailed output message when the assert ...
Mate Mrše's user avatar
  • 4,119
-1 votes
3 answers
2k views

How to open downloaded PDF file in Chrome and verify its content in Selenium?

When I click on the "Download PDF" link, the file is downloaded in Chrome. I need to open and verify the transaction data is correct in the file. I use Selenium and Java.
Raj87's user avatar
  • 1
-1 votes
1 answer
209 views

How to validate invalid date error message in Selenium Java project?

I have a "Date" field on my page I want to automate. Now, when I enter invalid value or invalid format, then its displays an error like: "This is invalid value for "Date" ...
qatester249's user avatar
-1 votes
2 answers
125 views

Unable to assert span content properly with Selenium and pytest

I want to check if a span element contains a certain text. It normally contains more text than I search for. That is what I do at the moment: assert self.driver.find_element_by_xpath("//td[@id='...
Hackerman's user avatar
-1 votes
1 answer
210 views

Assert for element, which is not displayed in the DOM

I've got a basic web payment form, which needs to be automately tested. The form contains five fields - email, card number, card month expiry, card year expiry and CVC code. Also, have two buttons - ...
locke's user avatar
  • 65
-2 votes
1 answer
2k views

How to convert a String to int on assert

Assert cannot be able to find value because it's expecting a String but an integer is present instead. How can I be able to convert this String to an integer. I tried using Integer.parseInt(number) ...
Thabiso Ditabe's user avatar