Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
4.0k views
by The go-to Tester (232 points)
edited by

I wrote automation using behave framework with Python.

I met an issue that i want to keep browser not close after test for debugging but can not.

My script: environment.py 

from behave import *
from selenium import *
from selenium import webdriver
import os

from selenium.webdriver.common.by import By

from constants.URL import *


def before_all(context):
    dir = CHROME_DRIVER
    chrome_driver_path = dir + "/chromedriver.exe"
    print(chrome_driver_path)
    context.browser = webdriver.Chrome(chrome_driver_path)
    context.browser.implicitly_wait(15)
    context.browser.maximize_window()
    # Login
    context.browser.get(URL_QUESTION_POST)

No function to close the browser after test finis, but it still close.

Please help to solve it!

by The go-to Tester (473 points)
moved by
Are you getting any error at the end of the script?

If yes then plz copy paste here. And check, after which step error is getting.
by The go-to Tester (181 points)
Can you post your after_all(context) or similar method? It looks like you are closing your browser in the after test method which gets executed after the execution is over.
by
I have not written after_all method because i do n not want to close it. I use behave framework and i dont know whether behave close browser automatically.
by The go-to Tester (181 points)
What is context here? Can you give the definition and declaration of the same? It might have quit function there.

Please log in or register to answer this question.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...