Refactor all existing selectors to utilize a more streamlined page object pattern
currently, we have all kinds of different methods of selection:
view '*.haml' do
element :settings_item #=> matches `.qa-settings-item`
element :settings_link, 'link_to edit_project_path' #=> matches on arbitrary rails renderer
element :link_text, "Issues" #=> matches on hardcoded link text
element :top_level_items, ".sidebar-top-level-items" #=> matches on CSS selector
...
end
I think it's important to keep a uniform method of selection. since we already have the .qa-* classes, i recommend we continue with that.
this would be a large refactoring work, but would be vital to GitLab QA success and to keep things uniform.
Proposition
- We continue using solely
.qa-*
selection - Extract selectors into standalone modules
- Modify
qa:selectors
to enforce.qa-*
selectors (this is at least partially complete [if not completely])
Example
QA::Page::Login
module QA
module Page
module Login
# let's also make all elements statically accessible, instead of writing interaction methods like #click_login_button()
view '...' do
element :username
element :password
element :login_button
end
def login(username, password)
set_text :username, username
set_text :password, password
click_element :login_button, [Page::Main::Dashboard] #=> refer to https://gitlab.com/gitlab-org/gitlab-qa/issues/280
end
end
end
end
qa/spec/features/login.rb [BEFORE]
module QA
describe 'standard user login', :core do
it 'user logs in using credentials' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
# TODO, since `Signed in successfully` message was removed
# this is the only way to tell if user is signed in correctly.
#
Page::Menu::Main.perform do |menu|
expect(menu).to have_personal_area
end
end
end
end
qa/spec/features/login.rb [AFTER]
module QA
describe 'standard user login', :core do
it 'user logs in using credentials' do
Page::Login.login('user', 'pass')
# in case we need it...
validate_text Page::Login.username, 'user'
...
end
end
end
this is more a brain dump, but hopefully it's at least 20% understandable.
/cc @gl-quality @meks @rymai