Skip to content

Error when call browse() after stop_browser() #40

@lf2a

Description

@lf2a

Describe the bug
Raises error when call browse() after stop_browser():

D:\BotCity\projetos\dev\web-test\venv\Scripts\python.exe D:/BotCity/projetos/dev/web-test/web.py
Traceback (most recent call last):
  File "D:\BotCity\projetos\dev\web-test\web.py", line 22, in <module>
    web.browse('https://github.com')
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\botcity\web\bot.py", line 855, in browse
    self.navigate_to(url)
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\botcity\web\bot.py", line 840, in navigate_to
    self.start_browser()
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\botcity\web\bot.py", line 230, in start_browser
    self._driver = driver_class(options=opt, desired_capabilities=cap, executable_path=driver_path)
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 166, in __init__
    capabilities.update(options.to_capabilities())
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\selenium\webdriver\firefox\options.py", line 180, in to_capabilities
    opts["profile"] = self._profile.encoded
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 173, in encoded
    self.update_preferences()
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 102, in update_preferences
    self._write_user_prefs(self.default_preferences)
  File "D:\BotCity\projetos\dev\web-test\venv\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 226, in _write_user_prefs
    with open(self.userPrefs, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\luizf\\AppData\\Local\\Temp\\tmp4ysamhb6\\webdriver-py-profilecopy\\user.js'

Process finished with exit code 1

Expected behavior
Open a new Firefox instance after stopping it.

Steps to Reproduce

import os
from botcity.web import WebBot, Browser

project_path = os.path.abspath('')

web = WebBot()
web.headless = False
web.browser = Browser.FIREFOX
web.driver_path = '<driver_path>'

# first task
web.browse('https://google.com')
web.wait(5_000)
web.stop_browser()

web.wait(5_000)

# second task
web.browse('https://github.com')
web.wait(5_000)
web.stop_browser()

My Platform
* OS: Windows 11
* Python Version: 3.10.2
* Packages Version: botcity-framework-web==0.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions