farnking / Test-Dragon-Forum-of-TBots

a fuzzer lab
1 stars 1 forks source link

'chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home #22

Open farnking opened 11 months ago

farnking commented 11 months ago

Describe the bug Can someone tell me how to set chromedriver.exe path location for starting selenium webdriver while executing our Test-Dragon?

Project ID Facebook, Chrome

Facebook Selenium webdriver could not find the path to chromedriver in windows.
This is not a problem for firefox geckodriver. Seems that geckodriver installation takes good care of PATH environment variables in Windows. Is there a way to set environment variable PATH from python in Windows?

Facebook login page in Chromedriver

URL

To Reproduce Just select the facebook project using Chrome. Maybe you have set the PATH environment variable correctly and would not see the bug in effect.

Expected behavior

call stack Exception has occurred: WebDriverException Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 13563, in __init__ service=Service(ChromeDriverManager().install()), ValueError: There is no such driver by url https://chromedriver.storage.googleapis.com/LATEST_RELEASE_118.0.5993 During handling of the above exception, another exception occurred: FileNotFoundError: [WinError 2] 系統找不到指定的檔案。 During handling of the above exception, another exception occurred: File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 13572, in __init__ self.driver = selenium.webdriver.Chrome("./chromedriver-win64/chromedriver.exe", chrome_options = chrome_options) File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 15514, in webDriverManagerFromForum downloadDir File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 71919, in start downloadDir File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 71858, in __init__ self.driver, self.processId = self.start() File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 30104, in __init__ self.__device = tMWebDefault_testingModuleWeb(self.__TD) File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 40103, in __init__ mainStateMac = CnStateMachine_CnStateMachine(self.__TD) File "C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\src\CnTestingTask.py", line 33913, in startMegaTBot self.proj = CnProjectManager_CnProject(self.__TD, self.curAppId, self.curProjectId, self.curProjectDict) selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
console output 'CnProjectManager_CnProject' object has no attribute '_CnProjectManager_CnProject__safeAppId' Finishing creating a email issueTracker obj for farn@ntu.edu.tw ! mosaic of RTS mosaic of RJDict mosaic of TBotCache FM appCacheDir: C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\.TestDragonCache\www.facebook.com displayOrientationPath: C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\.TestDragonCache\www.facebook.com\displayOrientation.txt [Thread-7][INFO] Lock 2220080210056 acquired on C:\Users\Farn\anaconda3\envs\taad\lib\site-packages\tldextract\.suffix_cache/publicsuffix.org-tlds\de84b5ca2167d4c83e38fb162f2e8738.tldextract.json.lock [Thread-7][INFO] Lock 2220269623112 acquired on C:\Users\Farn\anaconda3\envs\taad\lib\site-packages\tldextract\.suffix_cache/urls\62bf135d1c2f3d4db4228b9ecaf507a2.tldextract.json.lock [Thread-7][INFO] Lock 2220269623112 released on C:\Users\Farn\anaconda3\envs\taad\lib\site-packages\tldextract\.suffix_cache/urls\62bf135d1c2f3d4db4228b9ecaf507a2.tldextract.json.lock [Thread-7][INFO] Lock 2220080210056 released on C:\Users\Farn\anaconda3\envs\taad\lib\site-packages\tldextract\.suffix_cache/publicsuffix.org-tlds\de84b5ca2167d4c83e38fb162f2e8738.tldextract.json.lock Done urlAnalyzing: {'url': 'https://www.facebook.com/', 'scheme': 'https', 'fragment': None, 'queryStr': None, 'authority': 'www.facebook.com', 'path': '', 'user': None, 'port': None, 'subdomain': 'www', 'domain': 'facebook', 'suffix': 'com', 'domainPort': 'https://facebook.com', 'pathSegments': [''], 'query': {}, 'queryTemplate': None, 'urlQueryTemplate': 'https://www.facebook.com'} testing task init FM appCacheDir: C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\.TestDragonCache\www.facebook.com\traces Starting the DuT module! Resorting to the Web default module! Done urlAnalyzing: {'url': 'https://www.facebook.com/', 'scheme': 'https', 'fragment': None, 'queryStr': None, 'authority': 'www.facebook.com', 'path': '', 'user': None, 'port': None, 'subdomain': 'www', 'domain': 'facebook', 'suffix': 'com', 'domainPort': 'https://facebook.com', 'pathSegments': [''], 'query': {}, 'queryTemplate': None, 'urlQueryTemplate': 'https://www.facebook.com'} Starting the web test actioner! Starting the webViewDictManager module! Generating a random name: lxwrrcNU webdrivermanager: creating downloadDir! webDriverMan, using default driver path: C:\Users\Farn\Documents\realtime\PRGM\TestDragon\Client\pyxExperiment\.TestDragonCache\webdrivers The download folder is there! webDriverMan, trying preset options! webDriverMan, using preset options: [Thread-7][INFO] [Thread-7][INFO] ====== WebDriver manager ====== ====== WebDriver manager ====== Current google-chrome version is 118.0.5993 [Thread-7][INFO] Current google-chrome version is 118.0.5993 Get LATEST chromedriver version for 118.0.5993 google-chrome [Thread-7][INFO] Get LATEST chromedriver version for 118.0.5993 google-chrome % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1449 100 1449 0 0 1696 0 --:--:-- --:--:-- --:--:-- 1698 tar: Error opening archive: Unrecognized archive format

Screenshots

image image

Desktop (please complete the following information):

References explanation from Google

bernie6401 commented 11 months ago

看了一下整體的錯誤,應該是解壓縮出了問題,因為console顯示tar: Error opening archive: Unrecognized archive format,所以老師可以先看一下上一個command執行後下載了甚麼東西,再決定怎麼解壓縮

farnking commented 11 months ago

各位同學,我前幾天在電腦上要執行selenium chromedirver,結果他一直當,要自動下在又找不到。 後來仔細看程式碼,發現好像是這台電腦上的chrome設定跟chomedriver預設的下載URL不合。 在這種情況下會跳出一個exception,告知chromedriver與chrome不合,必須下載那個版本。

根據網路教學,我們就用下列程式碼來進行下載。

        except Exception as e:
            from webdriver_manager.chrome import ChromeDriverManager

            chromeDriverUrl = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/{0}.70/win64/chromedriver-win64.zip"

            chrome_driver_version = str(e).split("_")[-1]
            chromeDownloadUrl = chromeDriverUrl.format(chrome_driver_version)
            os.system(chromeDriverDownloadCmd.format(chromeDownloadUrl))
            os.system('tar -xf chromedriver-win64.zip')
            self.driver = selenium.webdriver.Chrome(
                "./chromedriver-win64/chromedriver.exe", chrome_options = chrome_options
            )

可是各位可以看出來,這段程式碼沒辦法全部自動化, 因為從exception中間抓下來的version號,只有三節數字,而下載需要四節數字,後面還要加一個70。

但問題試這個數字是不固定的,我上網去看,

https://googlechromelabs.github.io/chrome-for-testing/

這第四節數字有很多選擇,即使前三節數字一樣,這第四節也可能變動。 請問各位同學看,該怎麼解決?

bernie6401 commented 11 months ago

可以直接參考google的API,他是一個json file,可以直接選擇118的版本的最後一個sub-version,應該就是老師網站上看到的相對應的版本,就不需要知道他是哪一個version number,另外她還有附上download的連結,所以應該頗方便,詳細可以參考official github