11package core ;
22
3+ import static org .hamcrest .CoreMatchers .not ;
34import static org .hamcrest .MatcherAssert .assertThat ;
45import static org .jenkinsci .test .acceptance .Matchers .hasContent ;
56import static org .junit .Assert .assertFalse ;
6- import static org .junit .Assert .assertTrue ;
77
88import org .jenkinsci .test .acceptance .junit .AbstractJUnitTest ;
99import org .jenkinsci .test .acceptance .junit .Since ;
@@ -17,9 +17,9 @@ public class CreateItemTest extends AbstractJUnitTest {
1717 private static final String JOB_NAME = "asdf" ;
1818 private static final String NAME_FIELD = "name" ;
1919 private static final String JOB_CREATION_ERROR_MSG = "A job already exists" ;
20+ private static final String NAME_NOT_EMPTY_MSG = "This field cannot be empty, please enter a valid name" ;
21+ private static final String EXISTING_NAME_MSG = "A job already exists with the name ‘asdf’" ;
2022
21- private static final By NAME_NOT_EMPTY_MSG = by .id ("itemname-required" );
22- private static final By EXISTING_NAME_MSG = by .id ("itemname-invalid" );
2323 private static final By OK_BUTTON = by .id ("ok-button" );
2424
2525 @ Test
@@ -33,20 +33,17 @@ public void duplicate_item_name_displays_error() {
3333 fillIn (NAME_FIELD , JOB_NAME );
3434 blur (find (by .name (NAME_FIELD )));
3535
36- assertFalse ( findIfNotVisible ( NAME_NOT_EMPTY_MSG ). isDisplayed ( ));
37- assertTrue ( find (EXISTING_NAME_MSG ). isDisplayed ( ));
36+ assertThat ( driver , not ( hasContent ( NAME_NOT_EMPTY_MSG )));
37+ assertThat ( driver , hasContent (EXISTING_NAME_MSG ));
3838 assertFalse (find (OK_BUTTON ).isEnabled ());
3939
4040 // select type of job
4141 jenkins .jobs .findTypeCaption (FreeStyleJob .class ).click ();
4242
43- assertFalse ( findIfNotVisible ( NAME_NOT_EMPTY_MSG ). isDisplayed ( ));
44- assertTrue ( find (EXISTING_NAME_MSG ). isDisplayed ( ));
43+ assertThat ( driver , not ( hasContent ( NAME_NOT_EMPTY_MSG )));
44+ assertThat ( driver , hasContent (EXISTING_NAME_MSG ));
4545
4646 final WebElement okButtonElement = find (OK_BUTTON );
47- // TODO JENKINS-73034
48- // assertTrue(okButtonElement.isEnabled());
49-
5047 okButtonElement .click ();
5148 assertThat (driver , hasContent (JOB_CREATION_ERROR_MSG ));
5249 }
0 commit comments