About Pakistan, Software, Software Testing and every thing in between!!
Thursday, November 5, 2015
Sunday, October 25, 2015
Selenium, Jbehave , gradle and Serenity - Perfect combination for automating BDD styled checks in Java
I have just created this demo project using Selenium, gradle, Jbehave and Serenity
https://github.com/mubbashir/jbehave-selenium-bdd
The other things I loved about Serenity is the it has wonderful reports for BDD "Serenity also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works."
See:
https://github.com/mubbashir/jbehave-selenium-bdd
Why add Serenity?
Serenity adds plugins to Jbehave and makes it a lot easier to write acceptance tests as mentioned on it site Serenity BDD helps you write cleaner and more maintainable automated acceptance and regression tests faster.The other things I loved about Serenity is the it has wonderful reports for BDD "Serenity also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works."
See:
Structure
├── ReadMe.md ## ReadME file of cource ;)
├── build.gradle ## gradle build file
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew ## grdadle warapper
├── src
│ └── test
│ ├── java
│ │ └── test
│ │ ├── WebTest.java ## This is where the tests resides which add all the steps using net.serenitybdd.jbehave.SerenityStepFactory
│ │ └── selenium
│ │ ├── page ## This where all the pages extending net.serenitybdd.core.pages.PageObject
│ │ │ ├── google
│ │ │ │ └── GoogleLanding.java
│ │ │ └── interfaces
│ │ │ └── Landing.java
│ │ └── steps ## Pages are used in steps
│ │ └── GoogleSteps.java
│ └── resources
│ └── stories
│ └── google
│ ├── Search2.story
│ └── search.story
Refrences
- [jbehave]: http://jbehave.org/
- [gradle]: http://gradle.org/
- [serenity]: http://thucydides.info/docs/serenity/#first-steps
Tuesday, October 20, 2015
Adding pre-commit (package) to git repo of your python projects
Git pre commits are quite useful to analyze the code before you make a commit and pre-commit makes it quite easy to mange these hooks and rules to run via these hooks.
- Install pre-commit, pip install pre-commit ## detailed instruction on it's website pre-commit
- Run
pre-commit install
## Usage instruction on it's website pre-commit - Create .pre-commit-config.yaml file in your project root
- I have added it to behave-selenium, check it out
pre-commit install will install pre-commit into your git hooks, now on words it will be run on every commit.
Every time you clone a project running
pre-commit install
should always be the first thing you do.
The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.
- To Run all pre-commit manually on all file type
pre-commit run --all-files
- To run specific hook (via the id in .pre-commit-config.yaml) on specific file(s)
pre-commit run autopep8-wrapper --files features/steps/google_steps.py
We can also run all the pre commit hook as a CI step e.g. pre-commit run --all-files
Individual tools can configure in accordance to according to there configuration. For example flake8 can be configured by adding a setup.cfg file
Individual tools can configure in accordance to according to there configuration. For example flake8 can be configured by adding a setup.cfg file
Tuesday, October 6, 2015
Parallel execution of automated check via selenium, behave and docker
We were looking for a solution for executing selenium bases scenarios written in behave in parallel to speed up the execution time. Unluckily behave doesn't have this in build like cucumber fortunately we came across https://github.com/hugeinc/behave-parallel in which upstemsync was just couple of weeks old :)
I already had a picture in mind how would the entire step would work so creating a demo project wasn't too difficult.
Check out https://github.com/mubbashir/behave-selenium
Following is screen recoding where I had connected to both nodes via VNC and checks were executed in Parallel on features level
Links:
https://github.com/hugeinc/behave-parallel
https://github.com/behave/behave/
https://github.com/SeleniumHQ/docker-selenium
Following is what the readme says at the moment:
behave-selenium
Selenium's example using behave
A quick example of python, behave, selenium, webdriver and docker to run prallel tests
- Install docker and create a selenium grid with say 2 nodes
- docker run -d -p 4444:4444 --name selenium-hub selenium/hub:2.47.1 ## To Run the Hub
- docker run -d -P --link selenium-hub:hub selenium/node-firefox-debug:2.47.1 ## Run it twice to create 2 nodes, Docker will pick a random name
- Check the running docker containers
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
34911106818f selenium/node-firefox-debug:2.47.1 "/opt/bin/entry_point" 2 hours ago Up 2 hours 0.0.0.0:32769->5900/tcp condescending_elion
14971ef95408 selenium/node-firefox-debug:2.47.1 "/opt/bin/entry_point" 2 hours ago Up 2 hours 0.0.0.0:32768->5900/tcp trusting_mahavira
10688bf744d4 selenium/hub:2.47.1 "/opt/bin/entry_point" 3 hours ago Up 3 hours 0.0.0.0:4444->4444/tcp selenium-hub
- Selenium gird console to have two nodes http://192.168.99.100:4444/grid/console # if you are on mac or on windows get the ip of the running docker vm e.g.
docker-machine ip default
- Get port of VNC if you want to connect to a node
docker port <container-name|container-id> 5900
docker port 34911106818f
#=> 0.0.0.0:49338
- Clone the repo
- Create virtulenv
$virtualenv env
- Activate the virtualenv and run the requirements file via pip
source env/bin/activate; pip install -r requirements.txt
- Export GRID_HUB_URL
export GRID_HUB_URL='http://192.168.99.100:4444/wd/hub'
- Run
behave --processes 2 --parallel-element feature
Contributing
- Run the requiremetns file in the virtual environment
- Run
pre-commit install
## To install pre-commit
Run pre-commit install to install pre-commit into your git hooks. pre-commit will now run on every commit. Every time you clone this project running
pre-commit install
should always be the first thing you do.
If you want to manually run all pre-commit hooks on a repository,
run pre-commit run --all-files
. To run individual hooks use pre-commit run <hook_id>
.
The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow. For example: If the machine does not have node installed, pre-commit will download and build a copy of node.
- To Run all pre-commit manually on all file type
pre-commit run --all-files
- To run specific hook (via the id in .pre-commit-config.yaml) on specific file(s)
pre-commit run flake8 --files bdd_feature_tests/features/steps/dubizzle_homepage_steps.py
- To run autopep 8 manually (which will run automatically once pre-commit is configured) type
pre-commit run 'autopep8-wrapper' --files bdd_feature_tests/features/steps/dubizzle_homepage_steps.py
Wednesday, September 30, 2015
Flashback: Intro to Selenium and Automation- Slide deck
Flashback - Today while going through some documents on my google drive I came across this presentation which I have used in the past back to give very basic introduction to selenium and automation.
Tuesday, September 15, 2015
My Meeting with James Bach
Last Saturday I had the privileged to meet with James Bach (If you are a software tester, I expect you to know him) and as you can see below I was
He corrected my understanding of Oracles I was thinking about it too specific from the perspective of checks by focusing on pre defined rules whereas "In testing, an “oracle” is a way to recognise a problem that appears during testing."
We talk about check automation where he told me about this wonderful analogy that think of automated checks as a web and tester as Spider.
The spider is responsible for creating it, managing it, to find the right place and spot for it, a place where there is a greater chance to catch bugs and so on...
I told him briefly about STEP (Software Testers Engagement Programme) an initiative which bunch of my fellow testers took to bring closer the community
Can't express how excited I am :) and he played the dice game with me. Thank a lot @jamesmarcusbach for your time. pic.twitter.com/ZPwD0MfCll
— mubbashir (@mubbashir) September 12, 2015
I asked him about Sapient Testing->Non Scripted Testing->Testing vs Checking and how these 3 are different.He corrected my understanding of Oracles I was thinking about it too specific from the perspective of checks by focusing on pre defined rules whereas "In testing, an “oracle” is a way to recognise a problem that appears during testing."
We talk about check automation where he told me about this wonderful analogy that think of automated checks as a web and tester as Spider.
The spider is responsible for creating it, managing it, to find the right place and spot for it, a place where there is a greater chance to catch bugs and so on...
And then comes the best part when he played the Dice game with me
Just after few minutes in the game I felt myself bit overwhelmed :)
Few of the points I took as a take away after that session:
- Taking clear and correct (Yes correct) is extremely important
- Simplify problem: Start with the very basic try understand the system with the very basic data
- Don't get yourself too attached with the basic data, once you are sure how it is working for simple data - "Explore", "Randomise" and Look "Below the surface"
- Use Focus / Defocus heuristic when in doubt use focus when frustrated Defocus, walk around, change your perspective of viewing
While we were walking out of the coffee shop he saw me looking at his Cap (those who know me, would know why :-D I wear Cap all the time ) and then he told me he give Cap to tester who work for.
I have been told by @jamesmarcusbach that only @Lalitbhamare @huibschoots @CuriousTester and @testertested have His branded Cap #SoJealous
— mubbashir (@mubbashir) September 15, 2015
That got some responses with respect to who else has one :D
One thing which made me quite happy was that he was aware of what we Software Testers from Pakistan are doing at the moment mostly because of my dear friend @arslan0644
One thing which made me quite happy was that he was aware of what we Software Testers from Pakistan are doing at the moment mostly because of my dear friend @arslan0644
I told him briefly about STEP (Software Testers Engagement Programme) an initiative which bunch of my fellow testers took to bring closer the community
— mubbashir (@mubbashir) September 12, 2015
Thursday, September 3, 2015
Deleting facebook test users of your app
- Create a new user (We know how to do it, sending the key is sensitive so not adding here)
- You will get a response like:
{
- id: "137616849955555",
- access_token:"
CAAAAJ6uP3yMBAC56lfzUlZB3uwWms 0x6xXoriPn3ZAVko185KZCTxQaYADM qkXhpIH1VxAJtXzJBoNR7TNWKpRBoE AC79AY1VaGss93nHiqVGeZBEvHZALo uNw55PfZBujt1Up1PbjEryWB4iptNP F3PDAQuZAup4jGGRFUJeEs6JBvIEpo BvCQZCuB467oznCoE41zDbxFaVGnUR P1JdV9H", - email: "name_1441262612@tfbnw.
net", - password: "2073387096"
- Using the information from the above we can delete the user via the following:
Update the above URL by replacing TEST_USER_ID with the value of id from the first response and TEST_USER_ACCESS_TOKEN with the value of access_token from the first response
The response from it would be true.
Delete the test users once we are done.
Subscribe to:
Posts (Atom)