How to import a function from another folder

41 views
Skip to first unread message

Nikita Chavan

unread,
Jun 19, 2025, 12:27:43 AMJun 19
to Selenium Users
Hi,

Below is the code and I want to import get_clean_chrome_driver  function from drivers_setup file from Utils folder. I am getting module errors when I try to run from the top run button but it runs fine from terminal with pytest pages/test_all_blocks.py command. What could be the cause any idea?

test_all_blocks.py
import sys
import os
import time

# Dynamically add the project-level path so that Python can find utils/
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../utils")))

# Now you can safely import from utils
from drivers_setup import get_clean_chrome_driver


def name_print():
print("This is a placeholder function. Remove if unused.")

Capture.PNG
Reply all
Reply to author
Forward
0 new messages