Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP e2e testing #341

Merged
merged 43 commits into from
Mar 6, 2019
Merged

WIP e2e testing #341

merged 43 commits into from
Mar 6, 2019

Conversation

s-kennedy
Copy link
Contributor

I finally got around to the end to end testing! 🎉

Dirk, I ended up going with Selenium instead of the Mocha+Puppeteer tests. I think for end to end tests we really need to be able to access the database and Selenium lets us do that easily. I think the mocha/chai test setup is still going to be useful when we get around to unit testing the React components though. I would maybe just get rid of Puppeteer.

I added Selenium to the docker-compose.yml file, but we only want to use that image for testing, and I'm not sure how to do that. What do you think?

P.s. Merry Christmas ☃️

@s-kennedy s-kennedy force-pushed the e2e_testing branch 3 times, most recently from 326de7c to 1b26462 Compare December 27, 2018 22:55
@dirkcuys
Copy link
Member

Hey @s-kennedy, happy new year and all that!

Thanks for the update! I think it makes sense to use selenium, it allows you to access the database using the Django ORM like you mention and it keeps the tests more inline with the existing tests.

I'll look at updating the .travis.yml to run selenium for the tests.

@s-kennedy
Copy link
Contributor Author

Ok great thanks! I tried a couple different ways of updating the travis.yml file but I couldn't get it working, I always ran into this error:

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='selenium', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7faabb23f0f0>: Failed to establish a new connection: [Errno -2] Name does not resolve',))

Not sure if that's helpful or not, but I really hope we can get it working because I really liked working with selenium. Also we can add other browsers so we could run our tests on IE and Firefox as well!

@dirkcuys
Copy link
Member

That error was cause because we're connecting to a remote Selenium session for the tests. I've update the TravisCI to run a docker container with the selenium server and it's working now.

The only remaining issue is that tests sometimes time out?

@s-kennedy
Copy link
Contributor Author

Does it time out on the same test every time? Maybe it's missing a wait or something.

I was debugging by removing the --headless flag and using VNC viewer to see what's going on in the browser, maybe try that?

@dirkcuys
Copy link
Member

@s-kennedy I've tried a thousand things, but I think I've narrowed down the problem. For some reason it seems like the tests doesn't consistently select a course? I suspect a wait until is needed somewhere?

@s-kennedy
Copy link
Contributor Author

@dirkcuys ok, maybe it's moving to the next tab too quickly after the "Use this course" button is pressed? I'm not sure why that would matter because clicking the button just adds the course ID to the learning circle object, I don't think it should matter if the UI is updated or not. But you could put in a wait after the button is clicked for the "Remove selection" link to show up to verify the course is actually selected and see if that does the trick.

course_select_button = self.wait.until(expected_conditions.element_to_be_clickable(LearningCircleCreationPageLocators.FIRST_COURSE_BUTTON))
self.driver.execute_script("return arguments[0].scrollIntoView();", course_select_button)
course_select_button.click()

Copy link
Contributor Author

@s-kennedy s-kennedy Jan 19, 2019

Choose a reason for hiding this comment

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

was something like this already here? the page object is already there but it's not used anywhere else. Anyway this would check that the link to remove the course selection is there, to verify that the course has been selected.

self.wait.until(expected_conditions.presence_of_element_located(LearningCircleCreationPageLocators. REMOVE_COURSE_SELECTION_LINK))

@dirkcuys
Copy link
Member

Seems like the problem is with the chrome driver :( SeleniumHQ/selenium#4075

@dirkcuys
Copy link
Member

I tried working around this by sending the click via JavaScript:

course_select_button = self.wait.until(expected_conditions.element_to_be_clickable(LearningCircleCreationPageLocators.FIRST_COURSE_BUTTON))
self.driver.execute_script("return arguments[0].click();", course_select_button)

The linked issue says the issue is only with absolute positioned elements, but before I had issues with click on the tabs also.

Because a passing build doesn't mean the issue with inconsistent failures is sorted out, I'm hesitant to merge this PR.

@dirkcuys dirkcuys merged commit 4ed659a into master Mar 6, 2019
@dirkcuys dirkcuys deleted the e2e_testing branch March 6, 2019 08:43
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.

None yet

2 participants