Skip to content

Clear selenium tests code#515

Merged
stefanoborini merged 30 commits into
masterfrom
clear-selenium-tests
Jun 9, 2017
Merged

Clear selenium tests code#515
stefanoborini merged 30 commits into
masterfrom
clear-selenium-tests

Conversation

@martinRenou

@martinRenou martinRenou commented Jun 7, 2017

Copy link
Copy Markdown
Member
  • Add some routines for explicit wait
  • Add a routine for clicking elements
  • Remove the routine for clicking buttons (replaced by click_element(By.ID, "my-button"))
  • Use mostly ids instead of css_selector or class_names
  • Add some high level routines (login, logout, select_application(index=0), start_application, wait_until_application_started, click_new_entry_button, click_remove_user(index=0), ....)

@codecov-io

codecov-io commented Jun 7, 2017

Copy link
Copy Markdown

Codecov Report

Merging #515 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #515   +/-   ##
=======================================
  Coverage   95.25%   95.25%           
=======================================
  Files          88       88           
  Lines        3960     3960           
  Branches      248      248           
=======================================
  Hits         3772     3772           
  Misses        137      137           
  Partials       51       51

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41c0e29...27da0b0. Read the comment docs.

@martinRenou martinRenou changed the title Clear selenium tests code Clear selenium tests code [WIP] Jun 7, 2017
@martinRenou martinRenou requested a review from stefanoborini June 7, 2017 15:10
@martinRenou

martinRenou commented Jun 7, 2017

Copy link
Copy Markdown
Member Author

There is still some improvements to do, but I think it's enough for this PR. More routines for the AdminDriverTest will come with more tests later.

</div>
<button type="button" class="btn btn-default" @click="close()">Cancel</button>
<button class="btn btn-primary" type="submit" :disabled="formstate.$invalid">Submit</button>
<button id="modal-cancel-btn" type="button" class="btn btn-default" @click="close()">Cancel</button>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not put ids in generic components.

Comment thread selenium_tests/AdminDriverTest.py Outdated
self.wait_until_modal_closed()

def click_user_policies(self, index=0):
self.click_element_located(By.ID, "row-{}-action-0".format(index))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to namespace the id with respect to the table as well.

def wait_until_application_list_loaded(self):
self.wait_until_element_invisible(By.ID, "loading-spinner")

@contextlib.contextmanager

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need the context manager anymore. You can simply use the setup/teardown to login and logout specifically for your test cases.

Comment thread selenium_tests/test_create_new_user.py Outdated

class TestCreateNewUser(AdminDriverTest):
def test_cancel(self):
with self.logged_in():

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this goes away if you use setup/teardown on the base class.

@martinRenou martinRenou changed the title Clear selenium tests code [WIP] Clear selenium tests code Jun 8, 2017
Comment thread selenium_tests/AdminDriverTest.py Outdated
self.click_first_button("Cancel")
self.wait_until_modal_closed()

def trigger_row_action(self, row, action_name):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document better what is meant with row.

Comment thread selenium_tests/AdminDriverTest.py Outdated
def click_new_entry_button(self):
self.click_first_button("Create New Entry")

def click_submit_button(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submit of what?

Comment thread selenium_tests/AdminDriverTest.py Outdated
self.click_first_button("Submit")
self.wait_until_modal_closed()

def click_ok_button(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

click_dialog_ok_button

base_url=self.base_url))
db.commit()

def wait_until_presence_of_element_located(self, how, what):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these need docs.

def wait_until_modal_closed(self):
return self.wait.until_not(EC.alert_is_present())

def login(self, username="test"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this one.

def stop_application(self):
self.click_first_element_located(By.ID, "stop-button")

def start_application(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs

Comment thread selenium_tests/test_create_new_user.py Outdated
self.click_submit_button()

# Click remove button
self.trigger_row_action("mrenou", "Remove")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

click_row_action_button

@stefanoborini stefanoborini merged commit 9e2e9ae into master Jun 9, 2017
@stefanoborini stefanoborini deleted the clear-selenium-tests branch June 9, 2017 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants