0

Script running independently perfect. So no drive issue at all.

i have one webapplication in Odoo(its kind of webframework you can say) like Django. And i put button on my screen and add same code like above script. but its gives me error.

Exception occured!Message: session not created from tab crashed (Session info: headless chrome=89.0.4389.82)

This is my script.

import time
from selenium import webdriver

print(str(sys.argv[1]))

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
chrome_options.binary_location = '/usr/bin/google-chrome'
try:
    browser = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver",options=chrome_options)
    browser.get(sys.argv[1])
    time.sleep(5)

    browser.quit()
except Exception as error:
    print("\nException occured!" + str(error))

This is chromedriver log.

[1615546807.082][INFO]: Starting ChromeDriver 89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}) on port 40727
[1615546807.082][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1615546808.081][INFO]: [efb84f932f5a9088d79b04ddc066fdd2] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "args": [ "--headless", "--disable-dev-shm-usage", "--no-sandbox", "--enable-logging", "--log-lelvel=1" ],
            "binary": "/usr/bin/google-chrome",
            "extensions": [  ]
         },
         "platformName": "any"
      },
      "firstMatch": [ {

      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "goog:chromeOptions": {
         "args": [ "--headless", "--disable-dev-shm-usage", "--no-sandbox", "--enable-logging", "--log-lelvel=1" ],
         "binary": "/usr/bin/google-chrome",
         "extensions": [  ]
      },
      "platform": "ANY",
      "version": ""
   }
}
[1615546808.081][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1615546808.081][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[1615546808.082][INFO]: Launching chrome: /usr/bin/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --headless --log-lelvel=1 --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.Mikx1r data:,
[1615546808.260][INFO]: resolved localhost to ["127.0.0.1"]
[1615546808.802][INFO]: [efb84f932f5a9088d79b04ddc066fdd2] RESPONSE InitSession ERROR session not created
from tab crashed
  (Session info: headless chrome=89.0.4389.82)
tail: /tmp/chromedriver.log: file truncated
Balvant Ramani
  • 304
  • 1
  • 8
  • I think we need more info – piertoni Mar 12 '21 at 07:47
  • Yes tell me i can share what you need, i added my script. which running good. but same thing when i tried from my webapplication then giving above error. – Balvant Ramani Mar 12 '21 at 08:17
  • @BalvantRamani what do you mean, running using button? – Vova Mar 12 '21 at 08:30
  • @Vova i have one webapplication in Odoo(its kind of webframework you can say) like Django. And i put button on my screen and add same code like above script. but its gives me error. – Balvant Ramani Mar 12 '21 at 08:33
  • So you mean clicking on a button in the odoo app triggers this automation script ? – Madhan Mar 12 '21 at 08:42
  • @Madhan Yes and i also tried to put same script inside my app. but both have same result error. – Balvant Ramani Mar 12 '21 at 08:46
  • I am not sure its due to permission of chromedriver or google chrome inside /usr/bin to my webapplication user. – Balvant Ramani Mar 12 '21 at 08:47
  • Please check this post https://stackoverflow.com/questions/59186984/selenium-common-exceptions-sessionnotcreatedexception-message-session-not-crea . It may help you. – Madhan Mar 12 '21 at 08:54
  • @Madhan i followed thing already mentioned in your link. you can see in my script i already included param disable-dev-shm-usage – Balvant Ramani Mar 12 '21 at 09:02

0 Answers0