@@ -28,89 +28,64 @@ public BookmarksTests(AuthenticatedAccessibilityTestsFixture fixture)
2828 [ Fact ]
2929 public void BookmarksPageHasNoAccessibilityErrors ( )
3030 {
31+ // given
32+ const string resourceUrl = "/Resource/91/Item" ;
33+ const string addBookmarkPageUrl = "/bookmark/resource?bookmarked=False&title=Understanding%20and%20managing%20conflict%20in%20children%27s%20healthcare&rri=16593&returnUrl=%2FResource%2F16593%2FItem" ;
34+ const string myBookmarksPage = "/bookmark" ;
35+ const string bookmarkname = "Removal and disposal of Personal Protective Equipment (PPE)" ;
36+ IWebElement renameBookmarkElement = null ;
37+ IWebElement addBookmarkElement = null ;
38+ IWebElement moveBookmarkElement = null ;
39+ AxeResult addBookmarkPageResult = null ;
40+
41+ // when
42+ this . Driver . Navigate ( ) . GoToUrl ( this . BaseUrl + resourceUrl ) ;
3143 try
3244 {
33- // given
34- const string resourceUrl = "/Resource/91/Item" ;
35- const string addBookmarkPageUrl = "/bookmark/resource?bookmarked=False&title=Understanding%20and%20managing%20conflict%20in%20children%27s%20healthcare&rri=16593&returnUrl=%2FResource%2F16593%2FItem" ;
36- const string myBookmarksPage = "/bookmark" ;
37- const string bookmarkname = "Removal and disposal of Personal Protective Equipment (PPE)" ;
38- IWebElement renameBookmarkElement = null ;
39- IWebElement addBookmarkElement = null ;
40- IWebElement moveBookmarkElement = null ;
41- AxeResult addBookmarkPageResult = null ;
42-
43- // when
44- this . Driver . Navigate ( ) . GoToUrl ( this . BaseUrl + resourceUrl ) ;
45- try
46- {
47- addBookmarkElement = this . Driver . FindElement ( By . XPath ( "//a[contains(text(),'Add to my bookmarks')]" ) ) ;
48- if ( addBookmarkElement . Displayed )
49- {
50- this . Driver . ClickLinkContainingText ( "Add to my bookmarks" ) ;
51- this . ValidatePageHeading ( "Add bookmark" ) ;
52- addBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
53- this . Driver . ClickButtonByText ( "Continue" ) ;
54- }
55- }
56- catch ( NoSuchElementException )
45+ addBookmarkElement = this . Driver . FindElement ( By . XPath ( "//a[contains(text(),'Add to my bookmarks')]" ) ) ;
46+ if ( addBookmarkElement . Displayed )
5747 {
58- this . Driver . Navigate ( ) . GoToUrl ( this . BaseUrl + addBookmarkPageUrl ) ;
48+ this . Driver . ClickLinkContainingText ( "Add to my bookmarks" ) ;
5949 this . ValidatePageHeading ( "Add bookmark" ) ;
6050 addBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
61- this . Driver . ClickLinkContainingText ( "Cancel ") ;
51+ this . Driver . ClickButtonByText ( "Continue ") ;
6252 }
53+ }
54+ catch ( NoSuchElementException )
55+ {
56+ this . Driver . Navigate ( ) . GoToUrl ( this . BaseUrl + addBookmarkPageUrl ) ;
57+ this . ValidatePageHeading ( "Add bookmark" ) ;
58+ addBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
59+ this . Driver . ClickLinkContainingText ( "Cancel" ) ;
60+ }
6361
64- ////addBookmarkElement = this.Driver.FindElement(By.XPath("//a[contains(text(),'Add to my bookmarks')]"));
65- ////if (addBookmarkElement.Displayed)
66- ////{
67- //// this.Driver.ClickLinkContainingText("Add to my bookmarks");
68- //// this.ValidatePageHeading("Add bookmark");
69- //// addBookmarkPageResult = new AxeBuilder(this.Driver).Exclude("div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input").Analyze();
70- //// this.Driver.ClickButtonByText("Continue");
71- ////}
72- ////else
73- ////{
74- //// this.Driver.Navigate().GoToUrl(this.BaseUrl + addBookmarkPageUrl);
75- //// this.ValidatePageHeading("Add bookmark");
76- //// addBookmarkPageResult = new AxeBuilder(this.Driver).Exclude("div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input").Analyze();
77- //// this.Driver.ClickLinkContainingText("Cancel");
78- ////}
79-
80- this . Driver . Navigate ( ) . GoToUrl ( this . BaseUrl + myBookmarksPage ) ;
81- this . ValidatePageHeading ( "Bookmarked learning" ) ;
82- var myBookmarksPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
62+ this . Driver . Navigate ( ) . GoToUrl ( this . BaseUrl + myBookmarksPage ) ;
63+ this . ValidatePageHeading ( "Bookmarked learning" ) ;
64+ var myBookmarksPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
8365
84- this . Driver . ClickLinkContainingText ( "Add a folder" ) ;
85- this . ValidatePageHeading ( "Add a folder" ) ;
86- var addBookmarkFolderPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
87- this . Driver . ClickLinkContainingText ( "Cancel" ) ;
66+ this . Driver . ClickLinkContainingText ( "Add a folder" ) ;
67+ this . ValidatePageHeading ( "Add a folder" ) ;
68+ var addBookmarkFolderPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
69+ this . Driver . ClickLinkContainingText ( "Cancel" ) ;
8870
89- renameBookmarkElement = this . Driver . FindElement ( By . XPath ( $ "//tr[td//span[contains(text(), '{ bookmarkname } ')]]//td//div//form//span//button[contains(text(), 'Rename')]") ) ;
90- renameBookmarkElement . Click ( ) ;
91- this . ValidatePageHeading ( "Rename bookmark" ) ;
92- var renameBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
93- this . Driver . ClickLinkContainingText ( "Cancel" ) ;
71+ renameBookmarkElement = this . Driver . FindElement ( By . XPath ( $ "//tr[td//span[contains(text(), '{ bookmarkname } ')]]//td//div//form//span//button[contains(text(), 'Rename')]") ) ;
72+ renameBookmarkElement . Click ( ) ;
73+ this . ValidatePageHeading ( "Rename bookmark" ) ;
74+ var renameBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
75+ this . Driver . ClickLinkContainingText ( "Cancel" ) ;
9476
95- moveBookmarkElement = this . Driver . FindElement ( By . XPath ( $ "//tr[td//span[contains(text(), '{ bookmarkname } ')]]//td//div//form//span//button[contains(text(), 'Move')]") ) ;
96- moveBookmarkElement . Click ( ) ;
97- this . ValidatePageHeading ( "Move your bookmark" ) ;
98- var moveBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
99- this . Driver . ClickLinkContainingText ( "Cancel" ) ;
77+ moveBookmarkElement = this . Driver . FindElement ( By . XPath ( $ "//tr[td//span[contains(text(), '{ bookmarkname } ')]]//td//div//form//span//button[contains(text(), 'Move')]") ) ;
78+ moveBookmarkElement . Click ( ) ;
79+ this . ValidatePageHeading ( "Move your bookmark" ) ;
80+ var moveBookmarkPageResult = new AxeBuilder ( this . Driver ) . Exclude ( "div.nhsuk-radios--conditional div.nhsuk-radios__item input.nhsuk-radios__input" ) . Analyze ( ) ;
81+ this . Driver . ClickLinkContainingText ( "Cancel" ) ;
10082
101- // then
102- addBookmarkPageResult . Violations . Should ( ) . BeEmpty ( ) ;
103- myBookmarksPageResult . Violations . Should ( ) . BeEmpty ( ) ;
104- addBookmarkFolderPageResult . Violations . Should ( ) . BeEmpty ( ) ;
105- renameBookmarkPageResult . Violations . Should ( ) . BeEmpty ( ) ;
106- moveBookmarkPageResult . Violations . Should ( ) . BeEmpty ( ) ;
107- }
108- finally
109- {
110- // Close the browser window
111- this . Driver . Quit ( ) ;
112- this . Driver . Dispose ( ) ;
113- }
83+ // then
84+ addBookmarkPageResult . Violations . Where ( v => ! v . Tags . Contains ( "best-practice" ) ) . Should ( ) . BeEmpty ( ) ;
85+ myBookmarksPageResult . Violations . Where ( v => ! v . Tags . Contains ( "best-practice" ) ) . Should ( ) . BeEmpty ( ) ;
86+ addBookmarkFolderPageResult . Violations . Where ( v => ! v . Tags . Contains ( "best-practice" ) ) . Should ( ) . BeEmpty ( ) ;
87+ renameBookmarkPageResult . Violations . Where ( v => ! v . Tags . Contains ( "best-practice" ) ) . Should ( ) . BeEmpty ( ) ;
88+ moveBookmarkPageResult . Violations . Where ( v => ! v . Tags . Contains ( "best-practice" ) ) . Should ( ) . BeEmpty ( ) ;
11489 }
11590 }
11691}
0 commit comments