0
votes

Am a beginner trying to get the geolocation of my system

Have given all required permissions to chromedriver.exe present at /usr/bin

Have installed the required chromedriver

OS : ubuntu 18.04 Google Chrome 75.0.3770.142

Thanku for help

def getLocation():

options = Options()

options.add_argument("--use-fake-ui-for-media-stream")

timeout = 20

driver = webdriver.Chrome(executable_path=r'/usr/bin/chromedriver.exe', chrome_options=options)

driver.get("https://mycurrentlocation.net/")

wait = WebDriverWait(driver, timeout)

longitude = driver.find_elements_by_xpath('//*[@id="longitude"]')

longitude = [x.text for x in longitude]

longitude = str(longitude[0])

latitude = driver.find_elements_by_xpath('//*[@id="latitude"]')


latitude = [x.text for x in latitude]

latitude = str(latitude[0])

driver.quit()

return (latitude,longitude)

print(getLocation())

Traceback (most recent call last):

File "loca.py", line 24, in print(getLocation())

File "loca.py", line 12, in getLocation driver = webdriver.Chrome(executable_path =r'/usr/bin/chromedriver.exe', chrome_options=options)

File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities)

File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile)

File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters)

File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response)

File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

(unknown error: DevToolsActivePort file doesn't exist)

(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

1

1 Answers

0
votes
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

Are you using the correct linux binaries? Try downloading the correct binaries from: http://chromedriver.chromium.org/downloads or remove the ".exe" from the chromedriver path, could be a mistake since you're using ubuntu, not windows. It might be as simple as that.