{"id":63,"date":"2014-11-22T14:39:38","date_gmt":"2014-11-22T13:39:38","guid":{"rendered":"https:\/\/www.aleskrejci.cz\/blog\/?p=63"},"modified":"2014-11-22T14:39:38","modified_gmt":"2014-11-22T13:39:38","slug":"selenium-google-chrome","status":"publish","type":"post","link":"https:\/\/www.aleskrejci.cz\/blog\/2014\/11\/22\/selenium-google-chrome\/","title":{"rendered":"Selenium \u2013 google chrome"},"content":{"rendered":"<p>Pokud se v\u00e1m stane \u017ee p\u0159i spu\u0161t\u011bn\u00ed skriptu nap\u0159.:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">#!\/usr\/bin\/python\n# -*- coding: utf-8 -*-\n\nimport time\nfrom selenium import webdriver\n\nbrowser = webdriver.Chrome()\nbrowser.get(&#039;http:\/\/google.com\/&#039;)\ntime.sleep(3)\nbrowser.quit()<\/pre>\n<p>vysko\u010d\u00ed tato\u00a0hl\u00e1\u0161ka:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">Traceback (most recent call last):\n  File &quot;.\/test.py&quot;, line 7, in &lt;module&gt;;\n    browser = webdriver.Chrome()\n  File &quot;\/usr\/local\/lib\/python2.7\/dist-packages\/selenium\/webdriver\/chrome\/webdriver.py&quot;, line 59, in __init__\n    self.service.start()\n  File &quot;\/usr\/local\/lib\/python2.7\/dist-packages\/selenium\/webdriver\/chrome\/service.py&quot;, line 66, in start\n    &quot;ChromeDriver executable needs to be available in the path. &quot;\nselenium.common.exceptions.WebDriverException: Message: ChromeDriver executable needs to be available in the path. Please download from http:\/\/chromedriver.storage.googleapis.com\/index.html and read up at http:\/\/code.google.com\/p\/selenium\/wiki\/ChromeDriver<\/pre>\n<p>M\u016f\u017eete vyzkou\u0161et m\u016fj skript, kter\u00fd by m\u011bl v\u0161e vy\u0159e\u0161it \ud83d\ude42 .<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#!\/bin\/bash\n  \n&#x5B; &quot;x$USER&quot; != &#039;xroot&#039; ] &amp;&amp; echo &quot;Please run as root.&quot; &amp;&amp; exit 1\n \n# B: COMPONENTS INSTALL\nfunction fceGoogleChrome() {\n    if &#x5B; ! -s &quot;\/etc\/apt\/sources.list.d\/google-chrome.list&quot; ]; then\n        sudo sh -c &#039;echo &quot;deb http:\/\/dl.google.com\/linux\/chrome\/deb\/ stable main&quot; &gt;&gt; \/etc\/apt\/sources.list.d\/google-chrome.list&#039;\n        wget -O - &quot;https:\/\/dl-ssl.google.com\/linux\/linux_signing_key.pub&quot; | sudo apt-key add -\n        sudo apt-get update \n    fi\n    sudo apt-get install google-chrome-stable -y\n}\n \nfunction fceCheckInstaled() {\n    if ! dpkg-query -s $prog &gt; \/dev\/null 2&gt;&amp;1; then\n        echo $prog &quot;not installed&quot;\n        read -p &quot;Do you want to install (y\/n)? &quot;\n        if &#x5B;&#x5B; &quot;$REPLY&quot; == &quot;Y&quot; ||  &quot;$REPLY&quot; == &quot;y&quot; ]]; then\n            if &#x5B;&#x5B; $prog == &quot;google-chrome-stable&quot; ]]; then\n                fceGoogleChrome\n            else\n                sudo apt-get install $prog -y\n            fi\n        fi\n    fi\n}\n \nprogArray=(&quot;unzip&quot; &quot;curl&quot; &quot;wget&quot; &quot;python-pip&quot; &quot;google-chrome-stable&quot;)\nfor prog in ${progArray&#x5B;@]}\ndo\n    fceCheckInstaled\ndone\n \nsudo pip install selenium\n# E: COMPONENTS INSTALL\n \n \n# B: CHROMEDRIVER INSTALL\nVERSION=`curl &quot;http:\/\/chromedriver.storage.googleapis.com\/LATEST_RELEASE&quot;`\n \ncase $(uname -m) in\nx86_64)\n    NAME=&quot;chromedriver_linux64.zip&quot;\n    ;;\ni*86)\n    NAME=&quot;chromedriver_linux32.zip&quot;\n    ;;\n*)\n    echo &quot;ERROR: Unknown Architecture&quot;\n    exit\n    ;;\nesac\n \n \nwget -P \/tmp &quot;http:\/\/chromedriver.storage.googleapis.com\/&quot;$VERSION&quot;\/&quot;$NAME\n \nif &#x5B; -f \/tmp\/$NAME ]\nthen\n    sudo unzip \/tmp\/$NAME -d \/usr\/local\/share\n    sudo rm \/tmp\/$NAME\n \n    sudo chmod +x \/usr\/local\/share\/chromedriver\n \n    sudo ln -s \/usr\/local\/share\/chromedriver \/usr\/local\/bin\/chromedriver\n    sudo ln -s \/usr\/local\/share\/chromedriver \/usr\/bin\/chromedriver\nelse\n    echo &quot;File \/tmp\/&quot;$NAME&quot; not found&quot;\nfi\n# E:  CHROMEDRIVER INSTALL\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Pokud se v\u00e1m stane \u017ee p\u0159i spu\u0161t\u011bn\u00ed skriptu nap\u0159.: #!\/usr\/bin\/python # -*- coding: utf-8 -*- import time from selenium import webdriver browser = webdriver.Chrome() browser.get(&#039;http:\/\/google.com\/&#039;) time.sleep(3) browser.quit() vysko\u010d\u00ed tato\u00a0hl\u00e1\u0161ka: Traceback (most recent call last): File &quot;.\/test.py&quot;, line 7, in &lt;module&gt;; browser = webdriver.Chrome() File &quot;\/usr\/local\/lib\/python2.7\/dist-packages\/selenium\/webdriver\/chrome\/webdriver.py&quot;, line 59, in __init__ self.service.start() File &quot;\/usr\/local\/lib\/python2.7\/dist-packages\/selenium\/webdriver\/chrome\/service.py&quot;, line 66, in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[41,40],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-linux","tag-selenium","tag-fix-package"],"_links":{"self":[{"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":0,"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aleskrejci.cz\/blog\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}