When I try to execute a new unit test case it displays the below error.
Note: I do not have privilege to set the path due to the I have placed the chrome web driver in D drive.
Testing started at 14:56 ... C:\Users\xxx.xxxx\PycharmProjects\Automation\venv\Scripts\python.exe "C:\Users\xx.xxx\AppData\Local\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm_jb_unittest_runner.py" --path C:/Users/xx.xxx/PycharmProjects/Automation/UnitTest_1.py Launching unittests with arguments python -m unittest C:/Users/xx.xx/PycharmProjects/Automation/UnitTest_1.py in C:\Users\xx.xxx\PycharmProjects\Automation
Error Traceback (most recent call last): File "C:\xxxx\xxxxx\PycharmProjects\Automation\venv\lib\site-
packages\selenium\webdriver\common\service.py", line 76, in start stdin=PIPE) File "C:\Programs\Python\Python37-32\lib\subprocess.py", line 775, in init restore_signals, start_new_session) File "C:\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
When I handled the above exception, I got an another exception a below.
Traceback (most recent call last): File "C:\Programs\Python\Python37-32\lib\unittest\case.py", line 59, in testPartExecutor yield File "C:\Programs\Python\Python37-32\lib\unittest\case.py", line 615, in run testMethod() File "C:\xxxx\xxxxx\PycharmProjects\Automation\UnitTest_1.py", line 17, in test_Bing self.driver = webdriver.Chrome(executable_path="D:\test\chromedriver.exe") File "C:\xxxx\xxxx\PycharmProjects\Automation\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init self.service.start() File "C:\xxxx\xxxxx\PycharmProjects\Automation\venv\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home
Ran 2 tests in 2.374s
FAILED (errors=2) Error Traceback (most recent call last): File "C:\Programs\Python\Python37-32\lib\unittest\case.py", line 59, in testPartExecutor yield File "C:\Programs\Python\Python37-32\lib\unittest\case.py", line 615, in run testMethod() File "C:\Users\xxx.xxxx\PycharmProjects\Automation\UnitTest_1.py", line 10, in test_Google self.driver.get("www.google.com") File "C:\Users\xx.xxxx\PycharmProjects\Automation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "C:\Users\xx.xxxx\PycharmProjects\Automation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\xx.xxxxx\PycharmProjects\Automation\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: invalid argument (Session info: chrome=77.0.3865.90)
Assertion failed
Process finished with exit code 1
Assertion failed
Assertion failed
import os
os.environ["PATH"] += os.pathsep +r"D:\test\chromedriver.exe"
import unittest
from selenium import webdriver
class SearchEnginesTest(unittest.TestCase):
def test_Google(self):
self.driver = webdriver.Chrome(executable_path=r"D:\test\chromedriver.exe")
self.driver.get("www.google.com")
self.driver.maximize_window()
# self.driver.save_screenshot("D:\\test\\one.jpg")
print("Title of the page : " + self.driver.title)
self.driver.close()
def test_Bing(self):
self.driver = webdriver.Chrome(executable_path="D:\test\chromedriver.exe")
self.driver.get("www.bing.com")
self.driver.maximize_window()
# self.driver.save_screenshot("D:\\test\\two.jpg")
print("Title of the page: " + self.driver.title)
self.driver.close()
if __name__ == "__main__":
unittest.main()