For example, tried to locale a web page element by ID and it was not there - why Cucumber repeats the Java output (in addition to - expected - its own scenario/feature/steps failure text) and can I prevent that?
Testing started at 4:51 PM ...
Nov 28, 2018 4:51:48 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
================== Beginning ===================================
org.openqa.selenium.NoSuchElementException:
>>>ERROR. There is no Translation status column
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'T1650', ip: '10.68.1.61', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: driver.version: unknown
at pageObjects.VerificationPage.findStatusIcon(VerificationPage.java:40)
at stepDefinitions.VerificationPageSteps.user_verifies_translation_status(VerificationPageSteps.java:24)
at *.Then BitBucket user verifies Translation Status(C:/Verification/src/test/resources/features/Verification_Test.feature:11)
******************** Ending ***********************************
Failed scenarios:
c:/Verification/src/test/resources/features/Verification_Test.feature:8 # Scenario: User checks a repository
1 Scenarios (1 failed)
3 Steps (1 failed, 2 passed)
0m20.931s
org.openqa.selenium.NoSuchElementException:
>>>ERROR. There is no Translation status column
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'T1650', ip: '10.68.1.61', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: driver.version: unknown
at pageObjects.VerificationPage.findStatusIcon(VerificationPage.java:40)
at stepDefinitions.VerificationPageSteps.user_verifies_translation_status(VerificationPageSteps.java:24)
at *.Then BitBucket user verifies Translation Status(C:/Verification/src/test/resources/features/Verification_Test.feature:11)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Process finished with exit code 1
/
step definition (looks for a special column in Branches page of Bitbucket (stash)):
public class TranslationVerificationPageSteps {
private TestContext testContext;
private TranslationVerificationPage translationVerificationPage;
public TranslationVerificationPageSteps(TestContext context) {
testContext = context;
translationVerificationPage = testContext.getPageObjectManager().getTranslationVerificationPage();
}
@Then("^BitBucket user verifies Translation Status$")
public void user_verifies_translation_status(){
translationVerificationPage.findTranslationStatusIcon();
}
}
Implementation (just to show that I tried other ways - the majority of those commented out variants also produce that effect - Java/Selenium exception text is shown twice - or Java error text is not shown at all):
try {
translationColumn = driver.findElement(By.id("translation-status-branch-list-col"));
} catch (NoSuchElementException e) {
throw new NoSuchElementException("\n\n>>>ERROR. There is no Translation status column\n");
// variant 2
//Assert.fail("\n\n>>>ERROR. Test failed: no Translation status column\n\n");
// variant 3
// throw new AssertionError("\n\n>>>ERROR. Test failed: no Translation status column\n\n");
}
// variant 4
// try {
// Assert.assertNotNull(translationColumn);
//
// } catch (AssertionError foo) {
// System.out.println("\n\nTest failed: no Translation status column\n\n");
// //e.printStackTrace();
// //System.out.println(e.getMessage());
//
// }