from helium.bfs10063.system import bfs10163
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.service import Service as bfs10172
from selenium.webdriver.common import utils
from time import sleep
import os
import selenium
import selenium.webdriver.chrome.webdriver
import subprocess
import sys
def bfs10200():
  global bfs10174
  if (not bfs10173()):
    return 

  if (sys.version_info[:2] < (2, 7)):
    from _subprocess import STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW, SW_HIDE, CREATE_NEW_CONSOLE
  else:
    from subprocess import STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW, SW_HIDE, CREATE_NEW_CONSOLE

  class bfs10175(bfs10172):
    def start(self):
      env = (self.env or os.environ)
      try:
        bfs10176 = subprocess.STARTUPINFO()
        bfs10176.dwFlags = (STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW)
        bfs10176.wShowWindow = SW_HIDE
        bfs10176.hStdInput = open(os.devnull, 'r').fileno()
        bfs10176.hStdOutput = open(os.devnull, 'w').fileno()
        bfs10176.hStdError = open(os.devnull, 'w').fileno()
        self.process = subprocess.Popen(([self.path, ('--port=%d' % self.port)] + self.service_args), env=env, close_fds=True, creationflags=CREATE_NEW_CONSOLE, startupinfo=bfs10176)
      except:
        raise WebDriverException(('Could not execute ChromeDriver located at %s.' % self.path))

      count = 0
      while (not utils.is_connectable(self.port)):
        count += 1
        sleep(1)
        if (count == 30):
          raise WebDriverException('Can not connect to the ChromeDriver')




  selenium.webdriver.chrome.webdriver.Service = bfs10175
  bfs10174 = True

def bfs10173():
  if bfs10174:
    return False

  if (not bfs10163()):
    return False

  try:
    bfs10177 = tuple(map(int, selenium.__version__.split('.')))
  except:
    return False
  else:
    return (bfs10177 >= (2, 32, 0))


bfs10174 = False
