You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm new in bitbucket pipelines and also in behave, so any help I really appreciated.
I'm running behave BDD in bitbucket pipelines to execute 2 different features and is failing particularly the second one, in before_scenario method seems like it cannot create the driver or cannot open another session for the second time.
Is there any special code that I should include in the python script to run remotely when you want to execute more than one feature?
When I run only 1 feature the same pipeline script works perfectly.
This is the error:
pipelines:default:- step:name: TestBehaveimage: python:3.7.3script:- apt-get install unzip- pip install flask selenium requests behave- pip install webdriver-manager- behave -D env=testservices:- selenium-chromedefinitions:services:selenium-chrome:image: selenium/standalone-chromeenvironment:HUB_PORT_4444_TCP_ADDR: localhostHUB_PORT_4444_TCP_PORT: "4444"ports:- "4444:4444"
Hello @Daymi Morales Vega ,
Welcome to Atlassian Community!
The syntax you have used to define the service in your pipelines is slightly incorrect, as we currently don't support custom port mapping in service, we just currently support passing environment variables. The supported syntax and examples of defininig services in bitbucket pipelines can be checked in this documentation.
Having said that, I'm not very familiar with selenium itself, but from my research it seems that selenium by default allows only 1 concurrent session, and if you have more than one request, this request will be queued and timeout after a given amount of time if no slot becomes available.
Accordingly to selenium documentation, you can increase the session concurrency in the container, overriding the maximum limit, by setting both SE_NODE_MAX_SESSIONS to a desired number and SE_NODE_OVERRIDE_MAX_SESSIONS to true.
Alternatively, you also have the option to increase the time selenium waits before timing out when waiting for a slot. By default, a request will stay in the queue up to 300 seconds before a timeout is reached and an attempt to process the request is done every 5 seconds (by default). To change that you need to set the variables SE_SESSION_REQUEST_TIMEOUT and SE_SESSION_RETRY_INTERVAL
Please find below an example of bitbucket-pipelines.yml defining the selenium service to allow 2 concurrent sessions :
- sleep 15 # sleeps 15 seconds for the selenium service to start
- echo "This is a test to change selenium concurrency sessions"
This should make the selenium service to have 2 concurrent sessions available.
You can adjust the example above with your use case, and you also have the option to include the variables to change the session request timeout.
Hope that helps! Let me know in case you have any questions.
Thank you, @Daymi Morales Vega .
Hi @Patrik S
Thanks for answering. It is a great explanation for the problem and you go deeper in the answer with an example. I also noticed that the port is not supported and I removed it from de pipeline, but thanks for highlighting that.
I will accept your answer because is well elaborated and It makes sense to fix the Session time-out issue by changing the Selenium setup.
However, in my case, I had already solved it in another way. I finally found a solution by slightly changing the behave implementation. I read deeply in the behavior environmental control documentation and I notice that there are methods that run only once per environment, and I put the driver creation there. With this change, Selenium does not need to create more than one session because all the tests are running in the same driver/browser. Basically, I had the driver creation wrongly in the before_scenario method instead of in before_all method.
Thank you again, I'm sure this will help others if they run into the same error.