{"id":6096,"date":"2017-06-01T15:26:44","date_gmt":"2017-06-01T19:26:44","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=6096"},"modified":"2018-04-02T10:39:49","modified_gmt":"2018-04-02T14:39:49","slug":"chrome-not-reachable-error","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/chrome-not-reachable-error\/","title":{"rendered":"Chrome not reachable error when running Selenium test on Linux"},"content":{"rendered":"<p>I recently faced a <strong>Chrome not reachable<\/strong> error while running a Selenium test in Chrome browser on a Ubuntu machine. I had a hard time isolating the problem because I was trying to get setup with Chrome driver on Ubuntu as part of a Docker image.<\/p>\n<h3>Problem:<\/h3>\n<p>selenium.common.exceptions.WebDriverException: Message: chrome not reachable<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/06\/Chrome_Driver_Issue.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/06\/Chrome_Driver_Issue-300x148.jpg\" alt=\"Chrome Not reachable Issue\" width=\"569\" height=\"280\" class=\"aligncenter size-medium wp-image-6097\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/06\/Chrome_Driver_Issue-300x148.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2017\/06\/Chrome_Driver_Issue.jpg 569w\" sizes=\"auto, (max-width: 569px) 100vw, 569px\" \/><\/a><\/p>\n<hr>\n<h3>Solution:<\/h3>\n<p>Initially, I suspected the error is because of the below issues:<br \/>\n1. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Xvfb\">Xvfb<\/a> display, not getting set properly<br \/>\n2. Chrome driver version\/environment issue<\/p>\n<p>Even after making sure that these were set properly I still got this error. After quite a bit of Googling, I came across this particular <a href=\"https:\/\/stackoverflow.com\/questions\/29204780\/selenium-common-exceptions-webdriverexception-message-uchrome-not-reachable\">StackOverflow<\/a> solution which helped me resolve my issue. The solution was to add a couple of arguments (no-sandbox, disable-setuid-sandbox) when starting up Chrome.<\/p>\n<p>Since I did not understand the solution, I got more info on what Chrome&#8217;s Linux sandbox means from this <a href=\"http:\/\/www.insanitybit.com\/2013\/04\/29\/explaining-chromes-linux-sandbox\/\">link<\/a>. The Chrome-Sandbox SUID Helper Binary launches when Chrome does and sets up the sandbox environment. The sandbox environment is meant to be restrictive to the file system and other processes, attempting to isolate various Chrome parts (such as the renderer) from the system.<\/p>\n<p>Adding arguments to disable the sandbox and no sandbox helped me get past my issue and running my tests again<\/p>\n<pre lang=\"python\">#Selenium script to print the title of http:\/\/qxf2.com\r\nfrom selenium import webdriver\r\nfrom selenium.webdriver.chrome.options import Options\r\n\r\nchrome_options = Options()\r\n#argument to switch off suid sandBox and no sandBox in Chrome \r\nchrome_options.add_argument(\"--no-sandbox\")\r\nchrome_options.add_argument(\"--disable-setuid-sandbox\")\r\n\r\ndriver = webdriver.Chrome(chrome_options=chrome_options)\r\ndriver.get('http:\/\/qxf2.com')\r\nprint driver.title\r\ndriver.quit()\r\n<\/pre>\n<hr>\n<p>Hope this post helps you get past the <strong>Chrome not reachable error<\/strong>. Happy testing!<\/p>\n<p><strong>If you are a startup finding it hard to hire technical QA engineers, learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2 Services<\/a>.<\/strong><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>I recently faced a Chrome not reachable error while running a Selenium test in Chrome browser on a Ubuntu machine. I had a hard time isolating the problem because I was trying to get setup with Chrome driver on Ubuntu as part of a Docker image. Problem: selenium.common.exceptions.WebDriverException: Message: chrome not reachable Solution: Initially, I suspected the error is because [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[136,30,92],"tags":[],"class_list":["post-6096","post","type-post","status-publish","format-standard","hentry","category-chrome","category-selenium","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/6096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=6096"}],"version-history":[{"count":16,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/6096\/revisions"}],"predecessor-version":[{"id":15745,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/6096\/revisions\/15745"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=6096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=6096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=6096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}