Unable to trigger selenium scripts on selenium grid, working on local

I am running selenium python script through Selenium Grid, but it throws error “selenium.common.exceptions.WebDriverException: Message: Unable to find resource, invalid path in url.”
Below is Webdriver setup file

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
from selenium.webdriver.support.ui import WebDriverWait
import os

class WebDriverSetup:
    def __init__(self, grid_url, window_size="1920,1080", device_scale_factor="1", timeout=100):
        self.grid_url = grid_url # URL of the Selenium Grid hub
        self.path = r"path to driver.exe" 
        self.window_size = window_size
        self.device_scale_factor = device_scale_factor
        self.timeout = timeout
        self.driver = None
        self.wait = None

    def start_driver(self):
        # Set up Edge options
        print(self.grid_url)
        print(self.path)
        edge_options = Options()
        edge_options.add_argument(f"--force-device-scale-factor={self.device_scale_factor}")
        
        # Set download directory preferences
        download_dir = os.path.join(os.getcwd(), "downloads")
        if not os.path.exists(download_dir):
            os.makedirs(download_dir)
        edge_options.add_experimental_option("prefs", {
            "download.default_directory": download_dir,
            "download.prompt_for_download": False,
            "download.directory_upgrade": True,
        })

        # Create a remote WebDriver instance
        self.driver = webdriver.Remote(
            command_executor=self.grid_url,
            options=edge_options,
            # desired_capabilities=edge_options.to_capabilities()
        )

        # Maximize the browser window
        self.driver.maximize_window()

        self.wait = WebDriverWait(self.driver, self.timeout)

        return self.driver, self.wait
    
    def set_timeout(self, timeout):
        self.timeout = timeout
        self.wait = WebDriverWait(self.driver, self.timeout)
        # Example of changing timeout
        # webdriver_setup.set_timeout(200) in test file

    def stop_driver(self):
        if self.driver:
            self.driver.quit()

This is my test script

from selenium import webdriver
from selenium.webdriver.edge.options import Options
from utilities.webdriver_setup import WebDriverSetup  # Assuming your WebDriverSetup class is in webdriver_setup.py

grid_url = "http://localhost:4444/ui/"

webdriver_setup = WebDriverSetup(grid_url)

try:
    driver = None
    # Start WebDriver session on Selenium Grid
    driver, wait = webdriver_setup.start_driver()
    print("Driver started successfully")

    # Example: Navigate to a website
    driver.get("https://www.google.com")
    print(f"Title: {driver.title}")

    # Your test logic here

finally:
    # Ensure driver is stopped even if an exception occurs
    if driver:
        webdriver_setup.stop_driver()

Selenium grid : 4.22.0
Python : 3.10

I have ran the case on local but not able to trigger on selenium grid, throws me error “selenium.common.exceptions.WebDriverException: Message: Unable to find resource, invalid path in url.”.

New contributor

Rishabh Jain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Unable to trigger selenium scripts on selenium grid, working on local

I am running selenium python script through Selenium Grid, but it throws error “selenium.common.exceptions.WebDriverException: Message: Unable to find resource, invalid path in url.”
Below is Webdriver setup file

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
from selenium.webdriver.support.ui import WebDriverWait
import os

class WebDriverSetup:
    def __init__(self, grid_url, window_size="1920,1080", device_scale_factor="1", timeout=100):
        self.grid_url = grid_url # URL of the Selenium Grid hub
        self.path = r"path to driver.exe" 
        self.window_size = window_size
        self.device_scale_factor = device_scale_factor
        self.timeout = timeout
        self.driver = None
        self.wait = None

    def start_driver(self):
        # Set up Edge options
        print(self.grid_url)
        print(self.path)
        edge_options = Options()
        edge_options.add_argument(f"--force-device-scale-factor={self.device_scale_factor}")
        
        # Set download directory preferences
        download_dir = os.path.join(os.getcwd(), "downloads")
        if not os.path.exists(download_dir):
            os.makedirs(download_dir)
        edge_options.add_experimental_option("prefs", {
            "download.default_directory": download_dir,
            "download.prompt_for_download": False,
            "download.directory_upgrade": True,
        })

        # Create a remote WebDriver instance
        self.driver = webdriver.Remote(
            command_executor=self.grid_url,
            options=edge_options,
            # desired_capabilities=edge_options.to_capabilities()
        )

        # Maximize the browser window
        self.driver.maximize_window()

        self.wait = WebDriverWait(self.driver, self.timeout)

        return self.driver, self.wait
    
    def set_timeout(self, timeout):
        self.timeout = timeout
        self.wait = WebDriverWait(self.driver, self.timeout)
        # Example of changing timeout
        # webdriver_setup.set_timeout(200) in test file

    def stop_driver(self):
        if self.driver:
            self.driver.quit()

This is my test script

from selenium import webdriver
from selenium.webdriver.edge.options import Options
from utilities.webdriver_setup import WebDriverSetup  # Assuming your WebDriverSetup class is in webdriver_setup.py

grid_url = "http://localhost:4444/ui/"

webdriver_setup = WebDriverSetup(grid_url)

try:
    driver = None
    # Start WebDriver session on Selenium Grid
    driver, wait = webdriver_setup.start_driver()
    print("Driver started successfully")

    # Example: Navigate to a website
    driver.get("https://www.google.com")
    print(f"Title: {driver.title}")

    # Your test logic here

finally:
    # Ensure driver is stopped even if an exception occurs
    if driver:
        webdriver_setup.stop_driver()

Selenium grid : 4.22.0
Python : 3.10

I have ran the case on local but not able to trigger on selenium grid, throws me error “selenium.common.exceptions.WebDriverException: Message: Unable to find resource, invalid path in url.”.

New contributor

Rishabh Jain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật