Should I assert for existing before assertion for Selector property? - testing

Documentation states that "When a selector is executed, TestCafe waits for the target node to appear in the DOM until the selector timeout expires." and we don't use expect(Selector.exists).ok() in code sample below the statement. However in another paragraph we see that the Smart Assertion Query Mechanism does not wait for page elements to appear. If you need to wait for an element before executing an assertion, add another assertion that checks the selector’s count or exists property. and in code we see the .exist assertion (.expect(nameInput.exists).ok());
My question is: should I check for existence of an element of I can use assertions like expect(elementSelector[anyProperty]) without this pre-check?

No, you shouldn't check whether an element exists. I agree that the documentation indeed may be confusing. We have created an issue regarding this question:

Related

How to Continues execution with hard assertion on testNG?

After hard assertion give exception on testNG it moves to onTestFailure listener for screenshot, but execution is not continuing. How to continue the execution?
Not possible, once Assertions fails then it will throw exception.
see for example https://jitpack.io/com/github/cbeust/testng/master/javadoc/org/testng/Assert.html#assertEquals-java.lang.String-java.lang.String-
if need to continue after Assertion fails then need to handle that thrown exception, so need to use try/catch
But make a note that, when Assertions are handled by try/catch then test will be passed as exceptions are handled.
You can achieve it by using QAF TestNG extension. It provides Verify and assert methods. You can use validator as Below:
Validator.verifyThat(actual,Matchers.equalTo(expected));
Validator.verifyTrue(condition, failMessage, successMsg);
Validator.verifyFalse(condition, failMessage, successMsg);
Further more for web and mobile test it has inbuilt wait, verify and assert methods available with element object.

Why behat keeps request headers between different scenarios?

A header (Authorizathion) I set in the one scenario still exists when second scenario is ran.
I've looked through the documentation http://docs.behat.org/en/v3.0/ but I could find anything about my problem there.
Why is that ?
Use #insulated feature tag, this will start a clean browser for each scenario.
If this is not the issue use a method in #BeforeScenario hook where you can call reset/restart session methods.

Explicit selenium waits in intern

How can I use explicit waits using intern's leadfoot API for functional testing in intern?
There are multiple scenarios where I want to explicitly poll until a condition is met. For example, I want to wait until two or more elements exist in the DOM. Using findAllByCssSelector locks the execution for the whole implicit wait time instead of returning immediately after the condition is true.
All I can see that will help me is the pollUntil helper function, but it looks like this does not have access to any of the module dependencies defined in the test module.
How can I use something like jQuery within pollUntil?
findAllByCssSelector only waits for the implicit wait if no elements are found. If elements exist, the method finishes immediately with whatever it finds, so it's not ideal if you need to wait for a specific number of elements to appear.
pollUntil is the way to go for conditional waits. You are correct, though, that it doesn't have access to your module dependencies. Your dependencies are loaded in the context of Intern's test runner, while the pollUntil condition is going to run in the context of the browser. There are a couple ways to get the code you need into the browser. If you control the test page, you could just modify it to load whatever modules you need before the tests run. If you can't modify the test page, you could use an executeAsync call after loading the page in your test to inject whatever modules you need into the page context.

SOAP UI assertion

In SOAPUI, for content assertion can we put OR operation.
e.g
Status = failed OR Unauthorized
Thanks
I don't believe there is anyway to use OR operations between separate assertions but if you are just checking the content of a message you can use a regular expression inside your Contains Assertion like shown
indirectly this is possible. You can add the script assertion and use if condition.

assert and verify in Selenium

Can someone explain what the difference between assert and verify is please.
I know that verify means it checks if it is there, if it isn't the test fails and stops there (correct?).
So does assert carry on even if it does fail?
I've read the documentation and still can't get my head round it.
Nope, you've got it backwards. In Selenium IDE, both verifyWhatever and assertWhatever commands determine if the specified condition is true, and then different things happen. The assertWhatever command fails the test immediately if the condition is false. The verifywhatever command allows the test to continue, but will cause it to fail when it ends. Thus, if your test requires you to check for the presence of several items, none of which are present, assertElementPresent will fail on the first, while verifyElementPresent will fail reporting that all are missing.
The down side to verifyWhatever is that you really can't trust the behavior of any test after one of its verifications fails. Since the application isn't responding correctly, you have no way of knowing whether subsequent assertion or verification failures are valid or are the result of the earlier failures. Thus some of us think verifyWhatever commands are Evil.