问题
I created a script in Python, which scraps the Altium's website and gathers information regarding license usage. At this moment, I am using ChromeDriver, but I sometimes get errors due to the network being slow at different times of the day. I used the same script using the MicrosoftWebDriver (Edge) on my Personal Computer and I received no errors. When you launch the MicrosoftWebDriver.exe (downloaded from their website) it should open Edge, but when I use my company's laptop, nothing happens (see attached picture).
Is there any chance I can fix this? Is this happening as a result of the port being blocked?
This is the code I am using for selecting the webdriver:
browser = webdriver.Edge(r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
And this is the "error" I get:
And nothing happens after this...
The Python's Shell says this:
Traceback (most recent call last):
File "C:\ALTIUM_WORK\Altium_Python\Altium_H1.py", line 172, in <module>
browser = webdriver.Edge(r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 66, in __init__
desired_capabilities=capabilities)
File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Unknown error
回答1:
You need to pass the argument executable_path
as follows:
browser = webdriver.Edge(executable_path=r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
回答2:
This what solved the problem...
Local Security Policy -> Local Policies -> Security Options -> User Account Control: Run all administrators in Admin Approval Mode -> ENABLED
回答3:
browser = webdriver.Edge(r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
This is not working because in your office laptop User Account Control settings
is Turned Off
.
You need turned On User Account Control settings
and restart your machine and then run your code.It will work as expected.
To go to path on OS :
Control Panel-->All Control Panel Items-->User Accounts--> Change User Account Control settings
来源:https://stackoverflow.com/questions/55220205/selenium-common-exceptions-webdriverexception-message-unknown-error-while-tryi