As announced, I plan to publish my coding journal for each GitHub repository I create within my
#CodeConfident challenge. I've just finished the scope of my first challenge, so here are my related notes; as raw as they are, in chronological order. My hope is that they will serve three goals.
- Act as learning journal for myself, making my learning journey visible helping me acknowledge what I achieved
- Provide context for anyone who would like to check out my repository and maybe provide feedback and support
- Potentially provide a source of learning and inspiration for anyone else following my journey
Here's my journal for my first GitHub repository
serenity-cucumber-practice. Want to provide feedback on it or pair up with me on further challenges? I hereby
call for collaboration!
January 13
- start from Serenity Cucumber starter project (https://github.com/serenity-bdd/serenity-cucumber-starter)
- set up remote Chrome running Docker
- install TigerVNC for Windows
- revise scenario
- adapt step definitions -> still successful (gradlew clean test aggregate)
- create first page object and try to open it -> not compiling, packages to import "don't exist": "error: package net.serenitybdd.core.pages does not exist"
- TODO: fix issue
January 14
- followed instructions to have page objects in main>java, which resulted in lots of fruitless searching why I got a "error: package does not exist" and the class and import could not be added to the classpath by IntelliJ; tried lots of things until realizing the resolved dependencies are shown in External Libraries for each module in the packages sidebar (always checked in the projects view); move of page object to another place solved the issue
- "error: package net.serenitybdd.core.pages does not exist" -> realized it has to be in test as only there dependencies are resolved by gradle build
- Selenium Grid setup in Docker is working as usual
- TODO: Clean up and do first minimal commit
January 15
January 17
- generated SSH key and added it (all of https://help.github.com/articles/connecting-to-github-with-ssh/) -> worked like a charm, IntelliJ saves passphrase
- discovered https://desktop.github.com/ -> could delete old branch via UI
- first version of add item to cart scenario
- cleaned up a bit
- revising package structure: learned I need to put everything into one custom package, otherwise test runner fails
- TODO: improve first scenario, then implement second
January 20
January 24
January 26
- working on second scenario; request to add item to cart is sent successfully but the cart is empty - how to send a POST request with RestAssured: http://appsdeveloperblog.com/rest-assured-http-post-request/
- Postman offers option to copy full request in several programming languages
- problem: cannot replay request anymore in Postman; what changed?
- "?rand" query parameter is different on all requests, also for same session
- learned that cart product item is stored in the cookie; could set it to same value in FireFox
- learned I can set cookie for driver but first have to navigate to the page (https://stackoverflow.com/questions/45842709/unable-to-set-cookies-in-selenium-webdriver); also at best first delete other cookies; this works when I first set up the session for that cookie that it contains the named product; cannot repeat test like this
- with this workaround, managed to make the rest of the scenario work
- TODO: find out how to have cart reliably prepared
- can replay XHR request in browser; investigated how to send request via code (https://stackoverflow.com/questions/37654521/how-to-send-a-body-of-data-to-xmlhttprequest-that-looks-like-this)
- https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send
- found in source code: ajax-cart.js add to cart button on product page; also: ajax call in line 271; found that the "rand" query parameter is build of date and time; saw meaning of other parameters (add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist))
- researching how to send ajax / xhr request in Java
- https://howtodoinjava.com/ajax/complete-ajax-tutorial/
- maybe running in a wrong direction here; for a REST API I would have the solution already via RestAssured; maybe it should not even be allowed for a shop to add items to cart via API; how to build cookie then? but cookie value does not change when adding or removing items to the cart, so seems only identification of same user session, not more
- running out of ideas now
- frustrated that this scenario is a lot more than expected; wanted to frequently commit small things, feel I cannot right now; don't want to switch to easier scenarios unless I have to; if I have to, I'd like to do a rest assured repo next, need app with restful api then; could make things work if I don't use setup but click through it, it's just not what it's meant to be
- found another practice repo for that, did a workflow scenario: https://github.com/StMarco89/automationpractice.com
- overview page for official demo sites: http://www.seleniumframework.com/demo-sites/ there's a demo user account offered - but it's not working
- found interesting tutorials for selenium & cucumber: http://www.seleniumframework.com/cucumber-jvm-3/complete-hybrid-framework-implementation-3/
- tried Java way: https://www.baeldung.com/java-http-request also not working
- https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
- https://stackoverflow.com/questions/3324717/sending-http-post-request-in-java
- https://dzone.com/articles/how-to-implement-get-and-post-request-through-simp
- another option: ask for feedback how to do it, in own team or in community
- worked for 4.5-5h in a row, couldn't let go; time for a break
- idea after sleeping over it: implement other 2 more simple scenarios to fulfill the scope, have the not working one in a separate branch so I can still get feedback and support on it
January 29
January 30
- cleaned up branch
- split different test version into methods to keep code for feedback and be able to switch between them easier
- none of them is working, need feedback
- TODO: implement 2 other scenarios on master to finish scope and ask for feedback
February 5
February 6
- several potential scenarios to try
- tried to go for categories; stumbled across finding a good selector for menu element, was not interactable
- switched to extend the search feature by further scenarios; added view product page
- tried to add view product preview and again element was not interactable; found I was using the mobile site not the website for locating it!
- learned how to use actions to mouse over the element then the next element is interactable
- learned how to switch to an iframe (https://www.guru99.com/handling-iframes-selenium.html)
- merged latest master into branch
- TODO: write blog post with learnings, ask for feedback
Calling for Feedback
That's it so far, good enough for now!
Your feedback is appreciated.
"worked for 4.5-5h in a row, couldn't let go;" - I love that. Keep it up ;-)
ReplyDeleteThank you! Will do so ^^
Delete