示例#1
0
 def quit(self):
     """Quits the driver and close every associated window."""
     try:
         RemoteWebDriver.quit(self)
     except httplib.BadStatusLine:
         # Happens if Firefox shutsdown before we've read the response from
         # the socket.
         pass
     self.browser.kill()
示例#2
0
 def quit(self):
     """Quits the driver and close every associated window."""
     try:
       RemoteWebDriver.quit(self)
     except httplib.BadStatusLine:
       # Happens if Firefox shutsdown before we've read the response from
       # the socket.
       pass
     self.browser.kill()
示例#3
0
 def _execute(self, command, params=None):
     try:
         return RemoteWebDriver._execute(self, command, params)
     except ErrorInResponseException, e:
         # Legacy behavior: calling close() multiple times should not raise
         # an error
         if command != Command.CLOSE and command != Command.QUIT:
             raise e
示例#4
0
 def _execute(self, command, params=None):
     try:
         return RemoteWebDriver.execute(self, command, params)
     except ErrorInResponseException, e:
         # Legacy behavior: calling close() multiple times should not raise
         # an error
         if command != Command.CLOSE and command != Command.QUIT:
             raise e
示例#5
0
def _test():
    wd = RemoteWebDriver.connect('*chrome')
    wd.get("http://www.google.com")
    print "Current URL: %s" % wd.get_current_url()
    print "2 + 2 = %s" % wd.execute_script("return 2 + 2;")
    q = wd.find_element_by_name("q")
    q.send_keys("Sauce Labs")
    b = wd.find_element_by_name("btnG")
    b.click()
    wd.save_screenshot("google.jpg")
    print "Screenshot saved to google.jpg"
    wd.quit()
示例#6
0
    def __init__(self, profile=None, timeout=30):
        """Creates a webdriver instance.

        Args:
          profile: a FirefoxProfile object (it can also be a profile name,
                   but the support for that may be removed in future, it is
                   recommended to pass in a FirefoxProfile object)
          timeout: the amount of time to wait for extension socket
        """
        self.browser = FirefoxLauncher()
        if type(profile) == str:
            # This is to be Backward compatible because we used to take a
            # profile name
            profile = FirefoxProfile(name=profile)
        if not profile:
            profile = FirefoxProfile()
        self.browser.launch_browser(profile)
        RemoteWebDriver.__init__(self,
            command_executor=ExtensionConnection(timeout),
            browser_name='firefox', platform='ANY', version='',
            javascript_enabled=True)
示例#7
0
  def setUp(self):
    global WEBDRIVER_SERVER_URL
    global WEBDRIVER_PROCESS
    WEBDRIVER_PROCESS = subprocess.Popen([WEBDRIVER_EXE,
                                        '--port=%d' % WEBDRIVER_PORT])
    if WEBDRIVER_PROCESS == None:
      print "Chromium executable not found.  The path used was: "
      print WEBDRIVER_EXE
      sys.exit(-1)

    time.sleep(5)
    self.driver = WebDriver.WebDriver(WEBDRIVER_SERVER_URL, "chrome", "ANY")
    self.assertTrue(self.driver)
示例#8
0
    def __init__(self, port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT):
        self.port = port
        if self.port == 0:
            free_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            free_socket.bind((socket.gethostname(), 0))
            self.port = free_socket.getsockname()[1]
            free_socket.close()
        
        # Create IE Driver instance of the unmanaged code
        self.iedriver = CDLL(os.path.join(os.path.dirname(__file__), "IEDriver.dll"))
        self.ptr = self.iedriver.StartServer(self.port)

        seconds = 0
        while not self._is_connectable():
	    seconds += 1
	    if seconds > DEFAULT_TIMEOUT:
                raise RuntimeError("Unable to connect to IE")
            time.sleep(1)

        RemoteWebDriver.__init__(self,
			    command_executor='http://localhost:%d' % self.port,
			    browser_name='ie',
			    platform='WINDOWS', version='')
示例#9
0
    def __init__(self, profile=None, timeout=30):
        """Creates a webdriver instance.

        Args:
          profile: a FirefoxProfile object (it can also be a profile name,
                   but the support for that may be removed in future, it is
                   recommended to pass in a FirefoxProfile object)
          timeout: the amount of time to wait for extension socket
        """
        self.browser = FirefoxLauncher()
        if type(profile) == str:
            # This is to be Backward compatible because we used to take a
            # profile name
            profile = FirefoxProfile(name=profile)
        if not profile:
            profile = FirefoxProfile()
        self.browser.launch_browser(profile)
        RemoteWebDriver.__init__(self,
                                 command_executor=ExtensionConnection(timeout),
                                 browser_name='firefox',
                                 platform='ANY',
                                 version='',
                                 javascript_enabled=True)
示例#10
0
def setup_module(module):
    _socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_proc = None
    url = "http://%s:%d/wd/hub" % (SERVER_ADDR, DEFAULT_PORT)
    try:
        _socket.connect((SERVER_ADDR, DEFAULT_PORT))
        print ("The remote driver server is already running or something else"
               "is using port %d, continuing..." % DEFAULT_PORT)
    except:
        print ("Starting the remote driver server")
        RemoteApiExampleTest.server_proc = subprocess.Popen(
            "java -jar build/remote/server/server-standalone.jar",
            shell=True)

        assert wait_for_server(url, 10), "can't connect"
        print "Server should be online"

    webserver = SimpleWebServer()
    webserver.start()
    RemoteApiExampleTest.webserver = webserver
    RemoteApiExampleTest.driver = WebDriver(url, "firefox", "ANY")
示例#11
0
 def __init__(self):
     RemoteWebDriver.__init__(self,
         command_executor=ChromeDriver(),
         browser_name='chrome', platform='ANY', version='',
         javascript_enabled=True)
示例#12
0
 def __init__(self):
     RemoteWebDriver.__init__(self,
         command_executor=ChromeDriver(),
         browser_name='chrome', platform='ANY', version='',
         javascript_enabled=True)
示例#13
0
 def quit(self):
     RemoteWebDriver.quit(self)
     self.iedriver.StopServer(self.ptr)
     del self.iedriver
     del self.ptr