id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
21,100
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.set_script_timeout
def set_script_timeout(self, time_to_wait): """ Set the amount of time that the script should wait during an execute_async_script call before throwing an error. :Args: - time_to_wait: The amount of time to wait (in seconds) :Usage: :: driver.set_script_timeout(30) """ if self.w3c: self.execute(Command.SET_TIMEOUTS, { 'script': int(float(time_to_wait) * 1000)}) else: self.execute(Command.SET_SCRIPT_TIMEOUT, { 'ms': float(time_to_wait) * 1000})
python
def set_script_timeout(self, time_to_wait): """ Set the amount of time that the script should wait during an execute_async_script call before throwing an error. :Args: - time_to_wait: The amount of time to wait (in seconds) :Usage: :: driver.set_script_timeout(30) """ if self.w3c: self.execute(Command.SET_TIMEOUTS, { 'script': int(float(time_to_wait) * 1000)}) else: self.execute(Command.SET_SCRIPT_TIMEOUT, { 'ms': float(time_to_wait) * 1000})
[ "def", "set_script_timeout", "(", "self", ",", "time_to_wait", ")", ":", "if", "self", ".", "w3c", ":", "self", ".", "execute", "(", "Command", ".", "SET_TIMEOUTS", ",", "{", "'script'", ":", "int", "(", "float", "(", "time_to_wait", ")", "*", "1000", ")", "}", ")", "else", ":", "self", ".", "execute", "(", "Command", ".", "SET_SCRIPT_TIMEOUT", ",", "{", "'ms'", ":", "float", "(", "time_to_wait", ")", "*", "1000", "}", ")" ]
Set the amount of time that the script should wait during an execute_async_script call before throwing an error. :Args: - time_to_wait: The amount of time to wait (in seconds) :Usage: :: driver.set_script_timeout(30)
[ "Set", "the", "amount", "of", "time", "that", "the", "script", "should", "wait", "during", "an", "execute_async_script", "call", "before", "throwing", "an", "error", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L947-L965
21,101
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.set_page_load_timeout
def set_page_load_timeout(self, time_to_wait): """ Set the amount of time to wait for a page load to complete before throwing an error. :Args: - time_to_wait: The amount of time to wait :Usage: :: driver.set_page_load_timeout(30) """ try: self.execute(Command.SET_TIMEOUTS, { 'pageLoad': int(float(time_to_wait) * 1000)}) except WebDriverException: self.execute(Command.SET_TIMEOUTS, { 'ms': float(time_to_wait) * 1000, 'type': 'page load'})
python
def set_page_load_timeout(self, time_to_wait): """ Set the amount of time to wait for a page load to complete before throwing an error. :Args: - time_to_wait: The amount of time to wait :Usage: :: driver.set_page_load_timeout(30) """ try: self.execute(Command.SET_TIMEOUTS, { 'pageLoad': int(float(time_to_wait) * 1000)}) except WebDriverException: self.execute(Command.SET_TIMEOUTS, { 'ms': float(time_to_wait) * 1000, 'type': 'page load'})
[ "def", "set_page_load_timeout", "(", "self", ",", "time_to_wait", ")", ":", "try", ":", "self", ".", "execute", "(", "Command", ".", "SET_TIMEOUTS", ",", "{", "'pageLoad'", ":", "int", "(", "float", "(", "time_to_wait", ")", "*", "1000", ")", "}", ")", "except", "WebDriverException", ":", "self", ".", "execute", "(", "Command", ".", "SET_TIMEOUTS", ",", "{", "'ms'", ":", "float", "(", "time_to_wait", ")", "*", "1000", ",", "'type'", ":", "'page load'", "}", ")" ]
Set the amount of time to wait for a page load to complete before throwing an error. :Args: - time_to_wait: The amount of time to wait :Usage: :: driver.set_page_load_timeout(30)
[ "Set", "the", "amount", "of", "time", "to", "wait", "for", "a", "page", "load", "to", "complete", "before", "throwing", "an", "error", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L967-L986
21,102
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.get_screenshot_as_file
def get_screenshot_as_file(self, filename): """ Saves a screenshot of the current window to a PNG image file. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. This should end with a `.png` extension. :Usage: :: driver.get_screenshot_as_file('/Screenshots/foo.png') """ if not filename.lower().endswith('.png'): warnings.warn("name used for saved screenshot does not match file " "type. It should end with a `.png` extension", UserWarning) png = self.get_screenshot_as_png() try: with open(filename, 'wb') as f: f.write(png) except IOError: return False finally: del png return True
python
def get_screenshot_as_file(self, filename): """ Saves a screenshot of the current window to a PNG image file. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. This should end with a `.png` extension. :Usage: :: driver.get_screenshot_as_file('/Screenshots/foo.png') """ if not filename.lower().endswith('.png'): warnings.warn("name used for saved screenshot does not match file " "type. It should end with a `.png` extension", UserWarning) png = self.get_screenshot_as_png() try: with open(filename, 'wb') as f: f.write(png) except IOError: return False finally: del png return True
[ "def", "get_screenshot_as_file", "(", "self", ",", "filename", ")", ":", "if", "not", "filename", ".", "lower", "(", ")", ".", "endswith", "(", "'.png'", ")", ":", "warnings", ".", "warn", "(", "\"name used for saved screenshot does not match file \"", "\"type. It should end with a `.png` extension\"", ",", "UserWarning", ")", "png", "=", "self", ".", "get_screenshot_as_png", "(", ")", "try", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "png", ")", "except", "IOError", ":", "return", "False", "finally", ":", "del", "png", "return", "True" ]
Saves a screenshot of the current window to a PNG image file. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. This should end with a `.png` extension. :Usage: :: driver.get_screenshot_as_file('/Screenshots/foo.png')
[ "Saves", "a", "screenshot", "of", "the", "current", "window", "to", "a", "PNG", "image", "file", ".", "Returns", "False", "if", "there", "is", "any", "IOError", "else", "returns", "True", ".", "Use", "full", "paths", "in", "your", "filename", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1054-L1080
21,103
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.get_window_size
def get_window_size(self, windowHandle='current'): """ Gets the width and height of the current window. :Usage: :: driver.get_window_size() """ command = Command.GET_WINDOW_SIZE if self.w3c: if windowHandle != 'current': warnings.warn("Only 'current' window is supported for W3C compatibile browsers.") size = self.get_window_rect() else: size = self.execute(command, {'windowHandle': windowHandle}) if size.get('value', None) is not None: size = size['value'] return {k: size[k] for k in ('width', 'height')}
python
def get_window_size(self, windowHandle='current'): """ Gets the width and height of the current window. :Usage: :: driver.get_window_size() """ command = Command.GET_WINDOW_SIZE if self.w3c: if windowHandle != 'current': warnings.warn("Only 'current' window is supported for W3C compatibile browsers.") size = self.get_window_rect() else: size = self.execute(command, {'windowHandle': windowHandle}) if size.get('value', None) is not None: size = size['value'] return {k: size[k] for k in ('width', 'height')}
[ "def", "get_window_size", "(", "self", ",", "windowHandle", "=", "'current'", ")", ":", "command", "=", "Command", ".", "GET_WINDOW_SIZE", "if", "self", ".", "w3c", ":", "if", "windowHandle", "!=", "'current'", ":", "warnings", ".", "warn", "(", "\"Only 'current' window is supported for W3C compatibile browsers.\"", ")", "size", "=", "self", ".", "get_window_rect", "(", ")", "else", ":", "size", "=", "self", ".", "execute", "(", "command", ",", "{", "'windowHandle'", ":", "windowHandle", "}", ")", "if", "size", ".", "get", "(", "'value'", ",", "None", ")", "is", "not", "None", ":", "size", "=", "size", "[", "'value'", "]", "return", "{", "k", ":", "size", "[", "k", "]", "for", "k", "in", "(", "'width'", ",", "'height'", ")", "}" ]
Gets the width and height of the current window. :Usage: :: driver.get_window_size()
[ "Gets", "the", "width", "and", "height", "of", "the", "current", "window", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1145-L1165
21,104
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.get_window_position
def get_window_position(self, windowHandle='current'): """ Gets the x,y position of the current window. :Usage: :: driver.get_window_position() """ if self.w3c: if windowHandle != 'current': warnings.warn("Only 'current' window is supported for W3C compatibile browsers.") position = self.get_window_rect() else: position = self.execute(Command.GET_WINDOW_POSITION, {'windowHandle': windowHandle})['value'] return {k: position[k] for k in ('x', 'y')}
python
def get_window_position(self, windowHandle='current'): """ Gets the x,y position of the current window. :Usage: :: driver.get_window_position() """ if self.w3c: if windowHandle != 'current': warnings.warn("Only 'current' window is supported for W3C compatibile browsers.") position = self.get_window_rect() else: position = self.execute(Command.GET_WINDOW_POSITION, {'windowHandle': windowHandle})['value'] return {k: position[k] for k in ('x', 'y')}
[ "def", "get_window_position", "(", "self", ",", "windowHandle", "=", "'current'", ")", ":", "if", "self", ".", "w3c", ":", "if", "windowHandle", "!=", "'current'", ":", "warnings", ".", "warn", "(", "\"Only 'current' window is supported for W3C compatibile browsers.\"", ")", "position", "=", "self", ".", "get_window_rect", "(", ")", "else", ":", "position", "=", "self", ".", "execute", "(", "Command", ".", "GET_WINDOW_POSITION", ",", "{", "'windowHandle'", ":", "windowHandle", "}", ")", "[", "'value'", "]", "return", "{", "k", ":", "position", "[", "k", "]", "for", "k", "in", "(", "'x'", ",", "'y'", ")", "}" ]
Gets the x,y position of the current window. :Usage: :: driver.get_window_position()
[ "Gets", "the", "x", "y", "position", "of", "the", "current", "window", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1192-L1209
21,105
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.set_window_rect
def set_window_rect(self, x=None, y=None, width=None, height=None): """ Sets the x, y coordinates of the window as well as height and width of the current window. This method is only supported for W3C compatible browsers; other browsers should use `set_window_position` and `set_window_size`. :Usage: :: driver.set_window_rect(x=10, y=10) driver.set_window_rect(width=100, height=200) driver.set_window_rect(x=10, y=10, width=100, height=200) """ if not self.w3c: raise UnknownMethodException("set_window_rect is only supported for W3C compatible browsers") if (x is None and y is None) and (height is None and width is None): raise InvalidArgumentException("x and y or height and width need values") return self.execute(Command.SET_WINDOW_RECT, {"x": x, "y": y, "width": width, "height": height})['value']
python
def set_window_rect(self, x=None, y=None, width=None, height=None): """ Sets the x, y coordinates of the window as well as height and width of the current window. This method is only supported for W3C compatible browsers; other browsers should use `set_window_position` and `set_window_size`. :Usage: :: driver.set_window_rect(x=10, y=10) driver.set_window_rect(width=100, height=200) driver.set_window_rect(x=10, y=10, width=100, height=200) """ if not self.w3c: raise UnknownMethodException("set_window_rect is only supported for W3C compatible browsers") if (x is None and y is None) and (height is None and width is None): raise InvalidArgumentException("x and y or height and width need values") return self.execute(Command.SET_WINDOW_RECT, {"x": x, "y": y, "width": width, "height": height})['value']
[ "def", "set_window_rect", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "if", "not", "self", ".", "w3c", ":", "raise", "UnknownMethodException", "(", "\"set_window_rect is only supported for W3C compatible browsers\"", ")", "if", "(", "x", "is", "None", "and", "y", "is", "None", ")", "and", "(", "height", "is", "None", "and", "width", "is", "None", ")", ":", "raise", "InvalidArgumentException", "(", "\"x and y or height and width need values\"", ")", "return", "self", ".", "execute", "(", "Command", ".", "SET_WINDOW_RECT", ",", "{", "\"x\"", ":", "x", ",", "\"y\"", ":", "y", ",", "\"width\"", ":", "width", ",", "\"height\"", ":", "height", "}", ")", "[", "'value'", "]" ]
Sets the x, y coordinates of the window as well as height and width of the current window. This method is only supported for W3C compatible browsers; other browsers should use `set_window_position` and `set_window_size`. :Usage: :: driver.set_window_rect(x=10, y=10) driver.set_window_rect(width=100, height=200) driver.set_window_rect(x=10, y=10, width=100, height=200)
[ "Sets", "the", "x", "y", "coordinates", "of", "the", "window", "as", "well", "as", "height", "and", "width", "of", "the", "current", "window", ".", "This", "method", "is", "only", "supported", "for", "W3C", "compatible", "browsers", ";", "other", "browsers", "should", "use", "set_window_position", "and", "set_window_size", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1223-L1245
21,106
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.file_detector
def file_detector(self, detector): """ Set the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing. see FileDetector see LocalFileDetector see UselessFileDetector :Args: - detector: The detector to use. Must not be None. """ if detector is None: raise WebDriverException("You may not set a file detector that is null") if not isinstance(detector, FileDetector): raise WebDriverException("Detector has to be instance of FileDetector") self._file_detector = detector
python
def file_detector(self, detector): """ Set the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing. see FileDetector see LocalFileDetector see UselessFileDetector :Args: - detector: The detector to use. Must not be None. """ if detector is None: raise WebDriverException("You may not set a file detector that is null") if not isinstance(detector, FileDetector): raise WebDriverException("Detector has to be instance of FileDetector") self._file_detector = detector
[ "def", "file_detector", "(", "self", ",", "detector", ")", ":", "if", "detector", "is", "None", ":", "raise", "WebDriverException", "(", "\"You may not set a file detector that is null\"", ")", "if", "not", "isinstance", "(", "detector", ",", "FileDetector", ")", ":", "raise", "WebDriverException", "(", "\"Detector has to be instance of FileDetector\"", ")", "self", ".", "_file_detector", "=", "detector" ]
Set the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing. see FileDetector see LocalFileDetector see UselessFileDetector :Args: - detector: The detector to use. Must not be None.
[ "Set", "the", "file", "detector", "to", "be", "used", "when", "sending", "keyboard", "input", ".", "By", "default", "this", "is", "set", "to", "a", "file", "detector", "that", "does", "nothing", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1252-L1268
21,107
SeleniumHQ/selenium
py/selenium/webdriver/remote/webdriver.py
WebDriver.orientation
def orientation(self, value): """ Sets the current orientation of the device :Args: - value: orientation to set it to. :Usage: :: driver.orientation = 'landscape' """ allowed_values = ['LANDSCAPE', 'PORTRAIT'] if value.upper() in allowed_values: self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value}) else: raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'")
python
def orientation(self, value): """ Sets the current orientation of the device :Args: - value: orientation to set it to. :Usage: :: driver.orientation = 'landscape' """ allowed_values = ['LANDSCAPE', 'PORTRAIT'] if value.upper() in allowed_values: self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value}) else: raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'")
[ "def", "orientation", "(", "self", ",", "value", ")", ":", "allowed_values", "=", "[", "'LANDSCAPE'", ",", "'PORTRAIT'", "]", "if", "value", ".", "upper", "(", ")", "in", "allowed_values", ":", "self", ".", "execute", "(", "Command", ".", "SET_SCREEN_ORIENTATION", ",", "{", "'orientation'", ":", "value", "}", ")", "else", ":", "raise", "WebDriverException", "(", "\"You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'\"", ")" ]
Sets the current orientation of the device :Args: - value: orientation to set it to. :Usage: :: driver.orientation = 'landscape'
[ "Sets", "the", "current", "orientation", "of", "the", "device" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1283-L1299
21,108
SeleniumHQ/selenium
py/selenium/webdriver/support/wait.py
WebDriverWait.until
def until(self, method, message=''): """Calls the method provided with the driver as an argument until the \ return value does not evaluate to ``False``. :param method: callable(WebDriver) :param message: optional message for :exc:`TimeoutException` :returns: the result of the last call to `method` :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs """ screen = None stacktrace = None end_time = time.time() + self._timeout while True: try: value = method(self._driver) if value: return value except self._ignored_exceptions as exc: screen = getattr(exc, 'screen', None) stacktrace = getattr(exc, 'stacktrace', None) time.sleep(self._poll) if time.time() > end_time: break raise TimeoutException(message, screen, stacktrace)
python
def until(self, method, message=''): """Calls the method provided with the driver as an argument until the \ return value does not evaluate to ``False``. :param method: callable(WebDriver) :param message: optional message for :exc:`TimeoutException` :returns: the result of the last call to `method` :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs """ screen = None stacktrace = None end_time = time.time() + self._timeout while True: try: value = method(self._driver) if value: return value except self._ignored_exceptions as exc: screen = getattr(exc, 'screen', None) stacktrace = getattr(exc, 'stacktrace', None) time.sleep(self._poll) if time.time() > end_time: break raise TimeoutException(message, screen, stacktrace)
[ "def", "until", "(", "self", ",", "method", ",", "message", "=", "''", ")", ":", "screen", "=", "None", "stacktrace", "=", "None", "end_time", "=", "time", ".", "time", "(", ")", "+", "self", ".", "_timeout", "while", "True", ":", "try", ":", "value", "=", "method", "(", "self", ".", "_driver", ")", "if", "value", ":", "return", "value", "except", "self", ".", "_ignored_exceptions", "as", "exc", ":", "screen", "=", "getattr", "(", "exc", ",", "'screen'", ",", "None", ")", "stacktrace", "=", "getattr", "(", "exc", ",", "'stacktrace'", ",", "None", ")", "time", ".", "sleep", "(", "self", ".", "_poll", ")", "if", "time", ".", "time", "(", ")", ">", "end_time", ":", "break", "raise", "TimeoutException", "(", "message", ",", "screen", ",", "stacktrace", ")" ]
Calls the method provided with the driver as an argument until the \ return value does not evaluate to ``False``. :param method: callable(WebDriver) :param message: optional message for :exc:`TimeoutException` :returns: the result of the last call to `method` :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs
[ "Calls", "the", "method", "provided", "with", "the", "driver", "as", "an", "argument", "until", "the", "\\", "return", "value", "does", "not", "evaluate", "to", "False", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/wait.py#L62-L86
21,109
SeleniumHQ/selenium
py/selenium/webdriver/support/wait.py
WebDriverWait.until_not
def until_not(self, method, message=''): """Calls the method provided with the driver as an argument until the \ return value evaluates to ``False``. :param method: callable(WebDriver) :param message: optional message for :exc:`TimeoutException` :returns: the result of the last call to `method`, or ``True`` if `method` has raised one of the ignored exceptions :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs """ end_time = time.time() + self._timeout while True: try: value = method(self._driver) if not value: return value except self._ignored_exceptions: return True time.sleep(self._poll) if time.time() > end_time: break raise TimeoutException(message)
python
def until_not(self, method, message=''): """Calls the method provided with the driver as an argument until the \ return value evaluates to ``False``. :param method: callable(WebDriver) :param message: optional message for :exc:`TimeoutException` :returns: the result of the last call to `method`, or ``True`` if `method` has raised one of the ignored exceptions :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs """ end_time = time.time() + self._timeout while True: try: value = method(self._driver) if not value: return value except self._ignored_exceptions: return True time.sleep(self._poll) if time.time() > end_time: break raise TimeoutException(message)
[ "def", "until_not", "(", "self", ",", "method", ",", "message", "=", "''", ")", ":", "end_time", "=", "time", ".", "time", "(", ")", "+", "self", ".", "_timeout", "while", "True", ":", "try", ":", "value", "=", "method", "(", "self", ".", "_driver", ")", "if", "not", "value", ":", "return", "value", "except", "self", ".", "_ignored_exceptions", ":", "return", "True", "time", ".", "sleep", "(", "self", ".", "_poll", ")", "if", "time", ".", "time", "(", ")", ">", "end_time", ":", "break", "raise", "TimeoutException", "(", "message", ")" ]
Calls the method provided with the driver as an argument until the \ return value evaluates to ``False``. :param method: callable(WebDriver) :param message: optional message for :exc:`TimeoutException` :returns: the result of the last call to `method`, or ``True`` if `method` has raised one of the ignored exceptions :raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs
[ "Calls", "the", "method", "provided", "with", "the", "driver", "as", "an", "argument", "until", "the", "\\", "return", "value", "evaluates", "to", "False", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/wait.py#L88-L109
21,110
SeleniumHQ/selenium
py/selenium/webdriver/firefox/webdriver.py
WebDriver.quit
def quit(self): """Quits the driver and close every associated window.""" try: RemoteWebDriver.quit(self) except Exception: # We don't care about the message because something probably has gone wrong pass if self.w3c: self.service.stop() else: self.binary.kill() if self.profile is not None: try: shutil.rmtree(self.profile.path) if self.profile.tempfolder is not None: shutil.rmtree(self.profile.tempfolder) except Exception as e: print(str(e))
python
def quit(self): """Quits the driver and close every associated window.""" try: RemoteWebDriver.quit(self) except Exception: # We don't care about the message because something probably has gone wrong pass if self.w3c: self.service.stop() else: self.binary.kill() if self.profile is not None: try: shutil.rmtree(self.profile.path) if self.profile.tempfolder is not None: shutil.rmtree(self.profile.tempfolder) except Exception as e: print(str(e))
[ "def", "quit", "(", "self", ")", ":", "try", ":", "RemoteWebDriver", ".", "quit", "(", "self", ")", "except", "Exception", ":", "# We don't care about the message because something probably has gone wrong", "pass", "if", "self", ".", "w3c", ":", "self", ".", "service", ".", "stop", "(", ")", "else", ":", "self", ".", "binary", ".", "kill", "(", ")", "if", "self", ".", "profile", "is", "not", "None", ":", "try", ":", "shutil", ".", "rmtree", "(", "self", ".", "profile", ".", "path", ")", "if", "self", ".", "profile", ".", "tempfolder", "is", "not", "None", ":", "shutil", ".", "rmtree", "(", "self", ".", "profile", ".", "tempfolder", ")", "except", "Exception", "as", "e", ":", "print", "(", "str", "(", "e", ")", ")" ]
Quits the driver and close every associated window.
[ "Quits", "the", "driver", "and", "close", "every", "associated", "window", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/webdriver.py#L178-L197
21,111
SeleniumHQ/selenium
py/selenium/webdriver/firefox/webdriver.py
WebDriver.context
def context(self, context): """Sets the context that Selenium commands are running in using a `with` statement. The state of the context on the server is saved before entering the block, and restored upon exiting it. :param context: Context, may be one of the class properties `CONTEXT_CHROME` or `CONTEXT_CONTENT`. Usage example:: with selenium.context(selenium.CONTEXT_CHROME): # chrome scope ... do stuff ... """ initial_context = self.execute('GET_CONTEXT').pop('value') self.set_context(context) try: yield finally: self.set_context(initial_context)
python
def context(self, context): """Sets the context that Selenium commands are running in using a `with` statement. The state of the context on the server is saved before entering the block, and restored upon exiting it. :param context: Context, may be one of the class properties `CONTEXT_CHROME` or `CONTEXT_CONTENT`. Usage example:: with selenium.context(selenium.CONTEXT_CHROME): # chrome scope ... do stuff ... """ initial_context = self.execute('GET_CONTEXT').pop('value') self.set_context(context) try: yield finally: self.set_context(initial_context)
[ "def", "context", "(", "self", ",", "context", ")", ":", "initial_context", "=", "self", ".", "execute", "(", "'GET_CONTEXT'", ")", ".", "pop", "(", "'value'", ")", "self", ".", "set_context", "(", "context", ")", "try", ":", "yield", "finally", ":", "self", ".", "set_context", "(", "initial_context", ")" ]
Sets the context that Selenium commands are running in using a `with` statement. The state of the context on the server is saved before entering the block, and restored upon exiting it. :param context: Context, may be one of the class properties `CONTEXT_CHROME` or `CONTEXT_CONTENT`. Usage example:: with selenium.context(selenium.CONTEXT_CHROME): # chrome scope ... do stuff ...
[ "Sets", "the", "context", "that", "Selenium", "commands", "are", "running", "in", "using", "a", "with", "statement", ".", "The", "state", "of", "the", "context", "on", "the", "server", "is", "saved", "before", "entering", "the", "block", "and", "restored", "upon", "exiting", "it", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/webdriver.py#L209-L228
21,112
SeleniumHQ/selenium
py/selenium/webdriver/firefox/webdriver.py
WebDriver.install_addon
def install_addon(self, path, temporary=None): """ Installs Firefox addon. Returns identifier of installed addon. This identifier can later be used to uninstall addon. :param path: Absolute path to the addon that will be installed. :Usage: :: driver.install_addon('/path/to/firebug.xpi') """ payload = {"path": path} if temporary is not None: payload["temporary"] = temporary return self.execute("INSTALL_ADDON", payload)["value"]
python
def install_addon(self, path, temporary=None): """ Installs Firefox addon. Returns identifier of installed addon. This identifier can later be used to uninstall addon. :param path: Absolute path to the addon that will be installed. :Usage: :: driver.install_addon('/path/to/firebug.xpi') """ payload = {"path": path} if temporary is not None: payload["temporary"] = temporary return self.execute("INSTALL_ADDON", payload)["value"]
[ "def", "install_addon", "(", "self", ",", "path", ",", "temporary", "=", "None", ")", ":", "payload", "=", "{", "\"path\"", ":", "path", "}", "if", "temporary", "is", "not", "None", ":", "payload", "[", "\"temporary\"", "]", "=", "temporary", "return", "self", ".", "execute", "(", "\"INSTALL_ADDON\"", ",", "payload", ")", "[", "\"value\"", "]" ]
Installs Firefox addon. Returns identifier of installed addon. This identifier can later be used to uninstall addon. :param path: Absolute path to the addon that will be installed. :Usage: :: driver.install_addon('/path/to/firebug.xpi')
[ "Installs", "Firefox", "addon", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/webdriver.py#L230-L247
21,113
SeleniumHQ/selenium
py/selenium/webdriver/firefox/options.py
Options.binary
def binary(self, new_binary): """Sets location of the browser binary, either by string or ``FirefoxBinary`` instance. """ if not isinstance(new_binary, FirefoxBinary): new_binary = FirefoxBinary(new_binary) self._binary = new_binary
python
def binary(self, new_binary): """Sets location of the browser binary, either by string or ``FirefoxBinary`` instance. """ if not isinstance(new_binary, FirefoxBinary): new_binary = FirefoxBinary(new_binary) self._binary = new_binary
[ "def", "binary", "(", "self", ",", "new_binary", ")", ":", "if", "not", "isinstance", "(", "new_binary", ",", "FirefoxBinary", ")", ":", "new_binary", "=", "FirefoxBinary", "(", "new_binary", ")", "self", ".", "_binary", "=", "new_binary" ]
Sets location of the browser binary, either by string or ``FirefoxBinary`` instance.
[ "Sets", "location", "of", "the", "browser", "binary", "either", "by", "string", "or", "FirefoxBinary", "instance", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/options.py#L52-L59
21,114
SeleniumHQ/selenium
py/selenium/webdriver/firefox/options.py
Options.profile
def profile(self, new_profile): """Sets location of the browser profile to use, either by string or ``FirefoxProfile``. """ if not isinstance(new_profile, FirefoxProfile): new_profile = FirefoxProfile(new_profile) self._profile = new_profile
python
def profile(self, new_profile): """Sets location of the browser profile to use, either by string or ``FirefoxProfile``. """ if not isinstance(new_profile, FirefoxProfile): new_profile = FirefoxProfile(new_profile) self._profile = new_profile
[ "def", "profile", "(", "self", ",", "new_profile", ")", ":", "if", "not", "isinstance", "(", "new_profile", ",", "FirefoxProfile", ")", ":", "new_profile", "=", "FirefoxProfile", "(", "new_profile", ")", "self", ".", "_profile", "=", "new_profile" ]
Sets location of the browser profile to use, either by string or ``FirefoxProfile``.
[ "Sets", "location", "of", "the", "browser", "profile", "to", "use", "either", "by", "string", "or", "FirefoxProfile", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/options.py#L111-L118
21,115
SeleniumHQ/selenium
py/selenium/webdriver/remote/mobile.py
Mobile.set_network_connection
def set_network_connection(self, network): """ Set the network connection for the remote device. Example of setting airplane mode:: driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE) """ mode = network.mask if isinstance(network, self.ConnectionType) else network return self.ConnectionType(self._driver.execute( Command.SET_NETWORK_CONNECTION, { 'name': 'network_connection', 'parameters': {'type': mode}})['value'])
python
def set_network_connection(self, network): """ Set the network connection for the remote device. Example of setting airplane mode:: driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE) """ mode = network.mask if isinstance(network, self.ConnectionType) else network return self.ConnectionType(self._driver.execute( Command.SET_NETWORK_CONNECTION, { 'name': 'network_connection', 'parameters': {'type': mode}})['value'])
[ "def", "set_network_connection", "(", "self", ",", "network", ")", ":", "mode", "=", "network", ".", "mask", "if", "isinstance", "(", "network", ",", "self", ".", "ConnectionType", ")", "else", "network", "return", "self", ".", "ConnectionType", "(", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "SET_NETWORK_CONNECTION", ",", "{", "'name'", ":", "'network_connection'", ",", "'parameters'", ":", "{", "'type'", ":", "mode", "}", "}", ")", "[", "'value'", "]", ")" ]
Set the network connection for the remote device. Example of setting airplane mode:: driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
[ "Set", "the", "network", "connection", "for", "the", "remote", "device", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/mobile.py#L52-L64
21,116
SeleniumHQ/selenium
py/selenium/webdriver/remote/utils.py
unzip_to_temp_dir
def unzip_to_temp_dir(zip_file_name): """Unzip zipfile to a temporary directory. The directory of the unzipped files is returned if success, otherwise None is returned. """ if not zip_file_name or not os.path.exists(zip_file_name): return None zf = zipfile.ZipFile(zip_file_name) if zf.testzip() is not None: return None # Unzip the files into a temporary directory LOGGER.info("Extracting zipped file: %s" % zip_file_name) tempdir = tempfile.mkdtemp() try: # Create directories that don't exist for zip_name in zf.namelist(): # We have no knowledge on the os where the zipped file was # created, so we restrict to zip files with paths without # charactor "\" and "/". name = (zip_name.replace("\\", os.path.sep). replace("/", os.path.sep)) dest = os.path.join(tempdir, name) if (name.endswith(os.path.sep) and not os.path.exists(dest)): os.mkdir(dest) LOGGER.debug("Directory %s created." % dest) # Copy files for zip_name in zf.namelist(): # We have no knowledge on the os where the zipped file was # created, so we restrict to zip files with paths without # charactor "\" and "/". name = (zip_name.replace("\\", os.path.sep). replace("/", os.path.sep)) dest = os.path.join(tempdir, name) if not (name.endswith(os.path.sep)): LOGGER.debug("Copying file %s......" % dest) outfile = open(dest, 'wb') outfile.write(zf.read(zip_name)) outfile.close() LOGGER.debug("File %s copied." % dest) LOGGER.info("Unzipped file can be found at %s" % tempdir) return tempdir except IOError as err: LOGGER.error("Error in extracting webdriver.xpi: %s" % err) return None
python
def unzip_to_temp_dir(zip_file_name): """Unzip zipfile to a temporary directory. The directory of the unzipped files is returned if success, otherwise None is returned. """ if not zip_file_name or not os.path.exists(zip_file_name): return None zf = zipfile.ZipFile(zip_file_name) if zf.testzip() is not None: return None # Unzip the files into a temporary directory LOGGER.info("Extracting zipped file: %s" % zip_file_name) tempdir = tempfile.mkdtemp() try: # Create directories that don't exist for zip_name in zf.namelist(): # We have no knowledge on the os where the zipped file was # created, so we restrict to zip files with paths without # charactor "\" and "/". name = (zip_name.replace("\\", os.path.sep). replace("/", os.path.sep)) dest = os.path.join(tempdir, name) if (name.endswith(os.path.sep) and not os.path.exists(dest)): os.mkdir(dest) LOGGER.debug("Directory %s created." % dest) # Copy files for zip_name in zf.namelist(): # We have no knowledge on the os where the zipped file was # created, so we restrict to zip files with paths without # charactor "\" and "/". name = (zip_name.replace("\\", os.path.sep). replace("/", os.path.sep)) dest = os.path.join(tempdir, name) if not (name.endswith(os.path.sep)): LOGGER.debug("Copying file %s......" % dest) outfile = open(dest, 'wb') outfile.write(zf.read(zip_name)) outfile.close() LOGGER.debug("File %s copied." % dest) LOGGER.info("Unzipped file can be found at %s" % tempdir) return tempdir except IOError as err: LOGGER.error("Error in extracting webdriver.xpi: %s" % err) return None
[ "def", "unzip_to_temp_dir", "(", "zip_file_name", ")", ":", "if", "not", "zip_file_name", "or", "not", "os", ".", "path", ".", "exists", "(", "zip_file_name", ")", ":", "return", "None", "zf", "=", "zipfile", ".", "ZipFile", "(", "zip_file_name", ")", "if", "zf", ".", "testzip", "(", ")", "is", "not", "None", ":", "return", "None", "# Unzip the files into a temporary directory", "LOGGER", ".", "info", "(", "\"Extracting zipped file: %s\"", "%", "zip_file_name", ")", "tempdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "try", ":", "# Create directories that don't exist", "for", "zip_name", "in", "zf", ".", "namelist", "(", ")", ":", "# We have no knowledge on the os where the zipped file was", "# created, so we restrict to zip files with paths without", "# charactor \"\\\" and \"/\".", "name", "=", "(", "zip_name", ".", "replace", "(", "\"\\\\\"", ",", "os", ".", "path", ".", "sep", ")", ".", "replace", "(", "\"/\"", ",", "os", ".", "path", ".", "sep", ")", ")", "dest", "=", "os", ".", "path", ".", "join", "(", "tempdir", ",", "name", ")", "if", "(", "name", ".", "endswith", "(", "os", ".", "path", ".", "sep", ")", "and", "not", "os", ".", "path", ".", "exists", "(", "dest", ")", ")", ":", "os", ".", "mkdir", "(", "dest", ")", "LOGGER", ".", "debug", "(", "\"Directory %s created.\"", "%", "dest", ")", "# Copy files", "for", "zip_name", "in", "zf", ".", "namelist", "(", ")", ":", "# We have no knowledge on the os where the zipped file was", "# created, so we restrict to zip files with paths without", "# charactor \"\\\" and \"/\".", "name", "=", "(", "zip_name", ".", "replace", "(", "\"\\\\\"", ",", "os", ".", "path", ".", "sep", ")", ".", "replace", "(", "\"/\"", ",", "os", ".", "path", ".", "sep", ")", ")", "dest", "=", "os", ".", "path", ".", "join", "(", "tempdir", ",", "name", ")", "if", "not", "(", "name", ".", "endswith", "(", "os", ".", "path", ".", "sep", ")", ")", ":", "LOGGER", ".", "debug", "(", "\"Copying file %s......\"", "%", "dest", ")", "outfile", "=", "open", "(", "dest", ",", "'wb'", ")", "outfile", ".", "write", "(", "zf", ".", "read", "(", "zip_name", ")", ")", "outfile", ".", "close", "(", ")", "LOGGER", ".", "debug", "(", "\"File %s copied.\"", "%", "dest", ")", "LOGGER", ".", "info", "(", "\"Unzipped file can be found at %s\"", "%", "tempdir", ")", "return", "tempdir", "except", "IOError", "as", "err", ":", "LOGGER", ".", "error", "(", "\"Error in extracting webdriver.xpi: %s\"", "%", "err", ")", "return", "None" ]
Unzip zipfile to a temporary directory. The directory of the unzipped files is returned if success, otherwise None is returned.
[ "Unzip", "zipfile", "to", "a", "temporary", "directory", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/utils.py#L40-L90
21,117
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.tap
def tap(self, on_element): """ Taps on a given element. :Args: - on_element: The element to tap. """ self._actions.append(lambda: self._driver.execute( Command.SINGLE_TAP, {'element': on_element.id})) return self
python
def tap(self, on_element): """ Taps on a given element. :Args: - on_element: The element to tap. """ self._actions.append(lambda: self._driver.execute( Command.SINGLE_TAP, {'element': on_element.id})) return self
[ "def", "tap", "(", "self", ",", "on_element", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "SINGLE_TAP", ",", "{", "'element'", ":", "on_element", ".", "id", "}", ")", ")", "return", "self" ]
Taps on a given element. :Args: - on_element: The element to tap.
[ "Taps", "on", "a", "given", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L49-L58
21,118
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.double_tap
def double_tap(self, on_element): """ Double taps on a given element. :Args: - on_element: The element to tap. """ self._actions.append(lambda: self._driver.execute( Command.DOUBLE_TAP, {'element': on_element.id})) return self
python
def double_tap(self, on_element): """ Double taps on a given element. :Args: - on_element: The element to tap. """ self._actions.append(lambda: self._driver.execute( Command.DOUBLE_TAP, {'element': on_element.id})) return self
[ "def", "double_tap", "(", "self", ",", "on_element", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "DOUBLE_TAP", ",", "{", "'element'", ":", "on_element", ".", "id", "}", ")", ")", "return", "self" ]
Double taps on a given element. :Args: - on_element: The element to tap.
[ "Double", "taps", "on", "a", "given", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L60-L69
21,119
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.tap_and_hold
def tap_and_hold(self, xcoord, ycoord): """ Touch down at given coordinates. :Args: - xcoord: X Coordinate to touch down. - ycoord: Y Coordinate to touch down. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_DOWN, { 'x': int(xcoord), 'y': int(ycoord)})) return self
python
def tap_and_hold(self, xcoord, ycoord): """ Touch down at given coordinates. :Args: - xcoord: X Coordinate to touch down. - ycoord: Y Coordinate to touch down. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_DOWN, { 'x': int(xcoord), 'y': int(ycoord)})) return self
[ "def", "tap_and_hold", "(", "self", ",", "xcoord", ",", "ycoord", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "TOUCH_DOWN", ",", "{", "'x'", ":", "int", "(", "xcoord", ")", ",", "'y'", ":", "int", "(", "ycoord", ")", "}", ")", ")", "return", "self" ]
Touch down at given coordinates. :Args: - xcoord: X Coordinate to touch down. - ycoord: Y Coordinate to touch down.
[ "Touch", "down", "at", "given", "coordinates", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L71-L83
21,120
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.move
def move(self, xcoord, ycoord): """ Move held tap to specified location. :Args: - xcoord: X Coordinate to move. - ycoord: Y Coordinate to move. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_MOVE, { 'x': int(xcoord), 'y': int(ycoord)})) return self
python
def move(self, xcoord, ycoord): """ Move held tap to specified location. :Args: - xcoord: X Coordinate to move. - ycoord: Y Coordinate to move. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_MOVE, { 'x': int(xcoord), 'y': int(ycoord)})) return self
[ "def", "move", "(", "self", ",", "xcoord", ",", "ycoord", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "TOUCH_MOVE", ",", "{", "'x'", ":", "int", "(", "xcoord", ")", ",", "'y'", ":", "int", "(", "ycoord", ")", "}", ")", ")", "return", "self" ]
Move held tap to specified location. :Args: - xcoord: X Coordinate to move. - ycoord: Y Coordinate to move.
[ "Move", "held", "tap", "to", "specified", "location", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L85-L97
21,121
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.release
def release(self, xcoord, ycoord): """ Release previously issued tap 'and hold' command at specified location. :Args: - xcoord: X Coordinate to release. - ycoord: Y Coordinate to release. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_UP, { 'x': int(xcoord), 'y': int(ycoord)})) return self
python
def release(self, xcoord, ycoord): """ Release previously issued tap 'and hold' command at specified location. :Args: - xcoord: X Coordinate to release. - ycoord: Y Coordinate to release. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_UP, { 'x': int(xcoord), 'y': int(ycoord)})) return self
[ "def", "release", "(", "self", ",", "xcoord", ",", "ycoord", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "TOUCH_UP", ",", "{", "'x'", ":", "int", "(", "xcoord", ")", ",", "'y'", ":", "int", "(", "ycoord", ")", "}", ")", ")", "return", "self" ]
Release previously issued tap 'and hold' command at specified location. :Args: - xcoord: X Coordinate to release. - ycoord: Y Coordinate to release.
[ "Release", "previously", "issued", "tap", "and", "hold", "command", "at", "specified", "location", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L99-L111
21,122
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.scroll
def scroll(self, xoffset, yoffset): """ Touch and scroll, moving by xoffset and yoffset. :Args: - xoffset: X offset to scroll to. - yoffset: Y offset to scroll to. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_SCROLL, { 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
python
def scroll(self, xoffset, yoffset): """ Touch and scroll, moving by xoffset and yoffset. :Args: - xoffset: X offset to scroll to. - yoffset: Y offset to scroll to. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_SCROLL, { 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
[ "def", "scroll", "(", "self", ",", "xoffset", ",", "yoffset", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "TOUCH_SCROLL", ",", "{", "'xoffset'", ":", "int", "(", "xoffset", ")", ",", "'yoffset'", ":", "int", "(", "yoffset", ")", "}", ")", ")", "return", "self" ]
Touch and scroll, moving by xoffset and yoffset. :Args: - xoffset: X offset to scroll to. - yoffset: Y offset to scroll to.
[ "Touch", "and", "scroll", "moving", "by", "xoffset", "and", "yoffset", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L113-L125
21,123
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.scroll_from_element
def scroll_from_element(self, on_element, xoffset, yoffset): """ Touch and scroll starting at on_element, moving by xoffset and yoffset. :Args: - on_element: The element where scroll starts. - xoffset: X offset to scroll to. - yoffset: Y offset to scroll to. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_SCROLL, { 'element': on_element.id, 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
python
def scroll_from_element(self, on_element, xoffset, yoffset): """ Touch and scroll starting at on_element, moving by xoffset and yoffset. :Args: - on_element: The element where scroll starts. - xoffset: X offset to scroll to. - yoffset: Y offset to scroll to. """ self._actions.append(lambda: self._driver.execute( Command.TOUCH_SCROLL, { 'element': on_element.id, 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
[ "def", "scroll_from_element", "(", "self", ",", "on_element", ",", "xoffset", ",", "yoffset", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "TOUCH_SCROLL", ",", "{", "'element'", ":", "on_element", ".", "id", ",", "'xoffset'", ":", "int", "(", "xoffset", ")", ",", "'yoffset'", ":", "int", "(", "yoffset", ")", "}", ")", ")", "return", "self" ]
Touch and scroll starting at on_element, moving by xoffset and yoffset. :Args: - on_element: The element where scroll starts. - xoffset: X offset to scroll to. - yoffset: Y offset to scroll to.
[ "Touch", "and", "scroll", "starting", "at", "on_element", "moving", "by", "xoffset", "and", "yoffset", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L127-L141
21,124
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.long_press
def long_press(self, on_element): """ Long press on an element. :Args: - on_element: The element to long press. """ self._actions.append(lambda: self._driver.execute( Command.LONG_PRESS, {'element': on_element.id})) return self
python
def long_press(self, on_element): """ Long press on an element. :Args: - on_element: The element to long press. """ self._actions.append(lambda: self._driver.execute( Command.LONG_PRESS, {'element': on_element.id})) return self
[ "def", "long_press", "(", "self", ",", "on_element", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "LONG_PRESS", ",", "{", "'element'", ":", "on_element", ".", "id", "}", ")", ")", "return", "self" ]
Long press on an element. :Args: - on_element: The element to long press.
[ "Long", "press", "on", "an", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L143-L152
21,125
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.flick
def flick(self, xspeed, yspeed): """ Flicks, starting anywhere on the screen. :Args: - xspeed: The X speed in pixels per second. - yspeed: The Y speed in pixels per second. """ self._actions.append(lambda: self._driver.execute( Command.FLICK, { 'xspeed': int(xspeed), 'yspeed': int(yspeed)})) return self
python
def flick(self, xspeed, yspeed): """ Flicks, starting anywhere on the screen. :Args: - xspeed: The X speed in pixels per second. - yspeed: The Y speed in pixels per second. """ self._actions.append(lambda: self._driver.execute( Command.FLICK, { 'xspeed': int(xspeed), 'yspeed': int(yspeed)})) return self
[ "def", "flick", "(", "self", ",", "xspeed", ",", "yspeed", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "FLICK", ",", "{", "'xspeed'", ":", "int", "(", "xspeed", ")", ",", "'yspeed'", ":", "int", "(", "yspeed", ")", "}", ")", ")", "return", "self" ]
Flicks, starting anywhere on the screen. :Args: - xspeed: The X speed in pixels per second. - yspeed: The Y speed in pixels per second.
[ "Flicks", "starting", "anywhere", "on", "the", "screen", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L154-L166
21,126
SeleniumHQ/selenium
py/selenium/webdriver/common/touch_actions.py
TouchActions.flick_element
def flick_element(self, on_element, xoffset, yoffset, speed): """ Flick starting at on_element, and moving by the xoffset and yoffset with specified speed. :Args: - on_element: Flick will start at center of element. - xoffset: X offset to flick to. - yoffset: Y offset to flick to. - speed: Pixels per second to flick. """ self._actions.append(lambda: self._driver.execute( Command.FLICK, { 'element': on_element.id, 'xoffset': int(xoffset), 'yoffset': int(yoffset), 'speed': int(speed)})) return self
python
def flick_element(self, on_element, xoffset, yoffset, speed): """ Flick starting at on_element, and moving by the xoffset and yoffset with specified speed. :Args: - on_element: Flick will start at center of element. - xoffset: X offset to flick to. - yoffset: Y offset to flick to. - speed: Pixels per second to flick. """ self._actions.append(lambda: self._driver.execute( Command.FLICK, { 'element': on_element.id, 'xoffset': int(xoffset), 'yoffset': int(yoffset), 'speed': int(speed)})) return self
[ "def", "flick_element", "(", "self", ",", "on_element", ",", "xoffset", ",", "yoffset", ",", "speed", ")", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "FLICK", ",", "{", "'element'", ":", "on_element", ".", "id", ",", "'xoffset'", ":", "int", "(", "xoffset", ")", ",", "'yoffset'", ":", "int", "(", "yoffset", ")", ",", "'speed'", ":", "int", "(", "speed", ")", "}", ")", ")", "return", "self" ]
Flick starting at on_element, and moving by the xoffset and yoffset with specified speed. :Args: - on_element: Flick will start at center of element. - xoffset: X offset to flick to. - yoffset: Y offset to flick to. - speed: Pixels per second to flick.
[ "Flick", "starting", "at", "on_element", "and", "moving", "by", "the", "xoffset", "and", "yoffset", "with", "specified", "speed", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/touch_actions.py#L168-L185
21,127
SeleniumHQ/selenium
py/selenium/webdriver/remote/switch_to.py
SwitchTo.active_element
def active_element(self): """ Returns the element with focus, or BODY if nothing has focus. :Usage: :: element = driver.switch_to.active_element """ if self._driver.w3c: return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)['value'] else: return self._driver.execute(Command.GET_ACTIVE_ELEMENT)['value']
python
def active_element(self): """ Returns the element with focus, or BODY if nothing has focus. :Usage: :: element = driver.switch_to.active_element """ if self._driver.w3c: return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)['value'] else: return self._driver.execute(Command.GET_ACTIVE_ELEMENT)['value']
[ "def", "active_element", "(", "self", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "return", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "W3C_GET_ACTIVE_ELEMENT", ")", "[", "'value'", "]", "else", ":", "return", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "GET_ACTIVE_ELEMENT", ")", "[", "'value'", "]" ]
Returns the element with focus, or BODY if nothing has focus. :Usage: :: element = driver.switch_to.active_element
[ "Returns", "the", "element", "with", "focus", "or", "BODY", "if", "nothing", "has", "focus", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/switch_to.py#L34-L46
21,128
SeleniumHQ/selenium
py/selenium/webdriver/remote/switch_to.py
SwitchTo.frame
def frame(self, frame_reference): """ Switches focus to the specified frame, by index, name, or webelement. :Args: - frame_reference: The name of the window to switch to, an integer representing the index, or a webelement that is an (i)frame to switch to. :Usage: :: driver.switch_to.frame('frame_name') driver.switch_to.frame(1) driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0]) """ if isinstance(frame_reference, basestring) and self._driver.w3c: try: frame_reference = self._driver.find_element(By.ID, frame_reference) except NoSuchElementException: try: frame_reference = self._driver.find_element(By.NAME, frame_reference) except NoSuchElementException: raise NoSuchFrameException(frame_reference) self._driver.execute(Command.SWITCH_TO_FRAME, {'id': frame_reference})
python
def frame(self, frame_reference): """ Switches focus to the specified frame, by index, name, or webelement. :Args: - frame_reference: The name of the window to switch to, an integer representing the index, or a webelement that is an (i)frame to switch to. :Usage: :: driver.switch_to.frame('frame_name') driver.switch_to.frame(1) driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0]) """ if isinstance(frame_reference, basestring) and self._driver.w3c: try: frame_reference = self._driver.find_element(By.ID, frame_reference) except NoSuchElementException: try: frame_reference = self._driver.find_element(By.NAME, frame_reference) except NoSuchElementException: raise NoSuchFrameException(frame_reference) self._driver.execute(Command.SWITCH_TO_FRAME, {'id': frame_reference})
[ "def", "frame", "(", "self", ",", "frame_reference", ")", ":", "if", "isinstance", "(", "frame_reference", ",", "basestring", ")", "and", "self", ".", "_driver", ".", "w3c", ":", "try", ":", "frame_reference", "=", "self", ".", "_driver", ".", "find_element", "(", "By", ".", "ID", ",", "frame_reference", ")", "except", "NoSuchElementException", ":", "try", ":", "frame_reference", "=", "self", ".", "_driver", ".", "find_element", "(", "By", ".", "NAME", ",", "frame_reference", ")", "except", "NoSuchElementException", ":", "raise", "NoSuchFrameException", "(", "frame_reference", ")", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "SWITCH_TO_FRAME", ",", "{", "'id'", ":", "frame_reference", "}", ")" ]
Switches focus to the specified frame, by index, name, or webelement. :Args: - frame_reference: The name of the window to switch to, an integer representing the index, or a webelement that is an (i)frame to switch to. :Usage: :: driver.switch_to.frame('frame_name') driver.switch_to.frame(1) driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0])
[ "Switches", "focus", "to", "the", "specified", "frame", "by", "index", "name", "or", "webelement", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/switch_to.py#L73-L97
21,129
SeleniumHQ/selenium
py/selenium/webdriver/remote/switch_to.py
SwitchTo.new_window
def new_window(self, type_hint=None): """Switches to a new top-level browsing context. The type hint can be one of "tab" or "window". If not specified the browser will automatically select it. :Usage: :: driver.switch_to.new_window('tab') """ value = self._driver.execute(Command.NEW_WINDOW, {'type': type_hint})['value'] self._w3c_window(value['handle'])
python
def new_window(self, type_hint=None): """Switches to a new top-level browsing context. The type hint can be one of "tab" or "window". If not specified the browser will automatically select it. :Usage: :: driver.switch_to.new_window('tab') """ value = self._driver.execute(Command.NEW_WINDOW, {'type': type_hint})['value'] self._w3c_window(value['handle'])
[ "def", "new_window", "(", "self", ",", "type_hint", "=", "None", ")", ":", "value", "=", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "NEW_WINDOW", ",", "{", "'type'", ":", "type_hint", "}", ")", "[", "'value'", "]", "self", ".", "_w3c_window", "(", "value", "[", "'handle'", "]", ")" ]
Switches to a new top-level browsing context. The type hint can be one of "tab" or "window". If not specified the browser will automatically select it. :Usage: :: driver.switch_to.new_window('tab')
[ "Switches", "to", "a", "new", "top", "-", "level", "browsing", "context", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/switch_to.py#L99-L111
21,130
SeleniumHQ/selenium
py/selenium/webdriver/remote/switch_to.py
SwitchTo.window
def window(self, window_name): """ Switches focus to the specified window. :Args: - window_name: The name or window handle of the window to switch to. :Usage: :: driver.switch_to.window('main') """ if self._driver.w3c: self._w3c_window(window_name) return data = {'name': window_name} self._driver.execute(Command.SWITCH_TO_WINDOW, data)
python
def window(self, window_name): """ Switches focus to the specified window. :Args: - window_name: The name or window handle of the window to switch to. :Usage: :: driver.switch_to.window('main') """ if self._driver.w3c: self._w3c_window(window_name) return data = {'name': window_name} self._driver.execute(Command.SWITCH_TO_WINDOW, data)
[ "def", "window", "(", "self", ",", "window_name", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "_w3c_window", "(", "window_name", ")", "return", "data", "=", "{", "'name'", ":", "window_name", "}", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "SWITCH_TO_WINDOW", ",", "data", ")" ]
Switches focus to the specified window. :Args: - window_name: The name or window handle of the window to switch to. :Usage: :: driver.switch_to.window('main')
[ "Switches", "focus", "to", "the", "specified", "window", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/switch_to.py#L125-L141
21,131
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.perform
def perform(self): """ Performs all stored actions. """ if self._driver.w3c: self.w3c_actions.perform() else: for action in self._actions: action()
python
def perform(self): """ Performs all stored actions. """ if self._driver.w3c: self.w3c_actions.perform() else: for action in self._actions: action()
[ "def", "perform", "(", "self", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "perform", "(", ")", "else", ":", "for", "action", "in", "self", ".", "_actions", ":", "action", "(", ")" ]
Performs all stored actions.
[ "Performs", "all", "stored", "actions", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L75-L83
21,132
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.reset_actions
def reset_actions(self): """ Clears actions that are already stored locally and on the remote end """ if self._driver.w3c: self.w3c_actions.clear_actions() self._actions = []
python
def reset_actions(self): """ Clears actions that are already stored locally and on the remote end """ if self._driver.w3c: self.w3c_actions.clear_actions() self._actions = []
[ "def", "reset_actions", "(", "self", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "clear_actions", "(", ")", "self", ".", "_actions", "=", "[", "]" ]
Clears actions that are already stored locally and on the remote end
[ "Clears", "actions", "that", "are", "already", "stored", "locally", "and", "on", "the", "remote", "end" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L85-L91
21,133
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.click_and_hold
def click_and_hold(self, on_element=None): """ Holds down the left mouse button on an element. :Args: - on_element: The element to mouse down. If None, clicks on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.click_and_hold() self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.MOUSE_DOWN, {})) return self
python
def click_and_hold(self, on_element=None): """ Holds down the left mouse button on an element. :Args: - on_element: The element to mouse down. If None, clicks on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.click_and_hold() self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.MOUSE_DOWN, {})) return self
[ "def", "click_and_hold", "(", "self", ",", "on_element", "=", "None", ")", ":", "if", "on_element", ":", "self", ".", "move_to_element", "(", "on_element", ")", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "click_and_hold", "(", ")", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "MOUSE_DOWN", ",", "{", "}", ")", ")", "return", "self" ]
Holds down the left mouse button on an element. :Args: - on_element: The element to mouse down. If None, clicks on current mouse position.
[ "Holds", "down", "the", "left", "mouse", "button", "on", "an", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L112-L128
21,134
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.double_click
def double_click(self, on_element=None): """ Double-clicks an element. :Args: - on_element: The element to double-click. If None, clicks on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.double_click() for _ in range(4): self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.DOUBLE_CLICK, {})) return self
python
def double_click(self, on_element=None): """ Double-clicks an element. :Args: - on_element: The element to double-click. If None, clicks on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.double_click() for _ in range(4): self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.DOUBLE_CLICK, {})) return self
[ "def", "double_click", "(", "self", ",", "on_element", "=", "None", ")", ":", "if", "on_element", ":", "self", ".", "move_to_element", "(", "on_element", ")", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "double_click", "(", ")", "for", "_", "in", "range", "(", "4", ")", ":", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "DOUBLE_CLICK", ",", "{", "}", ")", ")", "return", "self" ]
Double-clicks an element. :Args: - on_element: The element to double-click. If None, clicks on current mouse position.
[ "Double", "-", "clicks", "an", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L149-L166
21,135
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.drag_and_drop
def drag_and_drop(self, source, target): """ Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button. :Args: - source: The element to mouse down. - target: The element to mouse up. """ self.click_and_hold(source) self.release(target) return self
python
def drag_and_drop(self, source, target): """ Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button. :Args: - source: The element to mouse down. - target: The element to mouse up. """ self.click_and_hold(source) self.release(target) return self
[ "def", "drag_and_drop", "(", "self", ",", "source", ",", "target", ")", ":", "self", ".", "click_and_hold", "(", "source", ")", "self", ".", "release", "(", "target", ")", "return", "self" ]
Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button. :Args: - source: The element to mouse down. - target: The element to mouse up.
[ "Holds", "down", "the", "left", "mouse", "button", "on", "the", "source", "element", "then", "moves", "to", "the", "target", "element", "and", "releases", "the", "mouse", "button", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L168-L179
21,136
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.drag_and_drop_by_offset
def drag_and_drop_by_offset(self, source, xoffset, yoffset): """ Holds down the left mouse button on the source element, then moves to the target offset and releases the mouse button. :Args: - source: The element to mouse down. - xoffset: X offset to move to. - yoffset: Y offset to move to. """ self.click_and_hold(source) self.move_by_offset(xoffset, yoffset) self.release() return self
python
def drag_and_drop_by_offset(self, source, xoffset, yoffset): """ Holds down the left mouse button on the source element, then moves to the target offset and releases the mouse button. :Args: - source: The element to mouse down. - xoffset: X offset to move to. - yoffset: Y offset to move to. """ self.click_and_hold(source) self.move_by_offset(xoffset, yoffset) self.release() return self
[ "def", "drag_and_drop_by_offset", "(", "self", ",", "source", ",", "xoffset", ",", "yoffset", ")", ":", "self", ".", "click_and_hold", "(", "source", ")", "self", ".", "move_by_offset", "(", "xoffset", ",", "yoffset", ")", "self", ".", "release", "(", ")", "return", "self" ]
Holds down the left mouse button on the source element, then moves to the target offset and releases the mouse button. :Args: - source: The element to mouse down. - xoffset: X offset to move to. - yoffset: Y offset to move to.
[ "Holds", "down", "the", "left", "mouse", "button", "on", "the", "source", "element", "then", "moves", "to", "the", "target", "offset", "and", "releases", "the", "mouse", "button", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L181-L194
21,137
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.move_by_offset
def move_by_offset(self, xoffset, yoffset): """ Moving the mouse to an offset from current mouse position. :Args: - xoffset: X offset to move to, as a positive or negative integer. - yoffset: Y offset to move to, as a positive or negative integer. """ if self._driver.w3c: self.w3c_actions.pointer_action.move_by(xoffset, yoffset) self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.MOVE_TO, { 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
python
def move_by_offset(self, xoffset, yoffset): """ Moving the mouse to an offset from current mouse position. :Args: - xoffset: X offset to move to, as a positive or negative integer. - yoffset: Y offset to move to, as a positive or negative integer. """ if self._driver.w3c: self.w3c_actions.pointer_action.move_by(xoffset, yoffset) self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.MOVE_TO, { 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
[ "def", "move_by_offset", "(", "self", ",", "xoffset", ",", "yoffset", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "move_by", "(", "xoffset", ",", "yoffset", ")", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "MOVE_TO", ",", "{", "'xoffset'", ":", "int", "(", "xoffset", ")", ",", "'yoffset'", ":", "int", "(", "yoffset", ")", "}", ")", ")", "return", "self" ]
Moving the mouse to an offset from current mouse position. :Args: - xoffset: X offset to move to, as a positive or negative integer. - yoffset: Y offset to move to, as a positive or negative integer.
[ "Moving", "the", "mouse", "to", "an", "offset", "from", "current", "mouse", "position", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L247-L263
21,138
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.move_to_element
def move_to_element(self, to_element): """ Moving the mouse to the middle of an element. :Args: - to_element: The WebElement to move to. """ if self._driver.w3c: self.w3c_actions.pointer_action.move_to(to_element) self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.MOVE_TO, {'element': to_element.id})) return self
python
def move_to_element(self, to_element): """ Moving the mouse to the middle of an element. :Args: - to_element: The WebElement to move to. """ if self._driver.w3c: self.w3c_actions.pointer_action.move_to(to_element) self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( Command.MOVE_TO, {'element': to_element.id})) return self
[ "def", "move_to_element", "(", "self", ",", "to_element", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "move_to", "(", "to_element", ")", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "MOVE_TO", ",", "{", "'element'", ":", "to_element", ".", "id", "}", ")", ")", "return", "self" ]
Moving the mouse to the middle of an element. :Args: - to_element: The WebElement to move to.
[ "Moving", "the", "mouse", "to", "the", "middle", "of", "an", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L265-L278
21,139
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.move_to_element_with_offset
def move_to_element_with_offset(self, to_element, xoffset, yoffset): """ Move the mouse by an offset of the specified element. Offsets are relative to the top-left corner of the element. :Args: - to_element: The WebElement to move to. - xoffset: X offset to move to. - yoffset: Y offset to move to. """ if self._driver.w3c: self.w3c_actions.pointer_action.move_to(to_element, xoffset, yoffset) self.w3c_actions.key_action.pause() else: self._actions.append( lambda: self._driver.execute(Command.MOVE_TO, { 'element': to_element.id, 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
python
def move_to_element_with_offset(self, to_element, xoffset, yoffset): """ Move the mouse by an offset of the specified element. Offsets are relative to the top-left corner of the element. :Args: - to_element: The WebElement to move to. - xoffset: X offset to move to. - yoffset: Y offset to move to. """ if self._driver.w3c: self.w3c_actions.pointer_action.move_to(to_element, xoffset, yoffset) self.w3c_actions.key_action.pause() else: self._actions.append( lambda: self._driver.execute(Command.MOVE_TO, { 'element': to_element.id, 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
[ "def", "move_to_element_with_offset", "(", "self", ",", "to_element", ",", "xoffset", ",", "yoffset", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "move_to", "(", "to_element", ",", "xoffset", ",", "yoffset", ")", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "MOVE_TO", ",", "{", "'element'", ":", "to_element", ".", "id", ",", "'xoffset'", ":", "int", "(", "xoffset", ")", ",", "'yoffset'", ":", "int", "(", "yoffset", ")", "}", ")", ")", "return", "self" ]
Move the mouse by an offset of the specified element. Offsets are relative to the top-left corner of the element. :Args: - to_element: The WebElement to move to. - xoffset: X offset to move to. - yoffset: Y offset to move to.
[ "Move", "the", "mouse", "by", "an", "offset", "of", "the", "specified", "element", ".", "Offsets", "are", "relative", "to", "the", "top", "-", "left", "corner", "of", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L280-L299
21,140
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.pause
def pause(self, seconds): """ Pause all inputs for the specified duration in seconds """ if self._driver.w3c: self.w3c_actions.pointer_action.pause(seconds) self.w3c_actions.key_action.pause(seconds) else: self._actions.append(lambda: time.sleep(seconds)) return self
python
def pause(self, seconds): """ Pause all inputs for the specified duration in seconds """ if self._driver.w3c: self.w3c_actions.pointer_action.pause(seconds) self.w3c_actions.key_action.pause(seconds) else: self._actions.append(lambda: time.sleep(seconds)) return self
[ "def", "pause", "(", "self", ",", "seconds", ")", ":", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "pause", "(", "seconds", ")", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", "seconds", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "time", ".", "sleep", "(", "seconds", ")", ")", "return", "self" ]
Pause all inputs for the specified duration in seconds
[ "Pause", "all", "inputs", "for", "the", "specified", "duration", "in", "seconds" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L301-L308
21,141
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.release
def release(self, on_element=None): """ Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. If None, releases on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.release() self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute(Command.MOUSE_UP, {})) return self
python
def release(self, on_element=None): """ Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. If None, releases on current mouse position. """ if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.release() self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute(Command.MOUSE_UP, {})) return self
[ "def", "release", "(", "self", ",", "on_element", "=", "None", ")", ":", "if", "on_element", ":", "self", ".", "move_to_element", "(", "on_element", ")", "if", "self", ".", "_driver", ".", "w3c", ":", "self", ".", "w3c_actions", ".", "pointer_action", ".", "release", "(", ")", "self", ".", "w3c_actions", ".", "key_action", ".", "pause", "(", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "MOUSE_UP", ",", "{", "}", ")", ")", "return", "self" ]
Releasing a held mouse button on an element. :Args: - on_element: The element to mouse up. If None, releases on current mouse position.
[ "Releasing", "a", "held", "mouse", "button", "on", "an", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L310-L325
21,142
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.send_keys
def send_keys(self, *keys_to_send): """ Sends keys to current focused element. :Args: - keys_to_send: The keys to send. Modifier keys constants can be found in the 'Keys' class. """ typing = keys_to_typing(keys_to_send) if self._driver.w3c: for key in typing: self.key_down(key) self.key_up(key) else: self._actions.append(lambda: self._driver.execute( Command.SEND_KEYS_TO_ACTIVE_ELEMENT, {'value': typing})) return self
python
def send_keys(self, *keys_to_send): """ Sends keys to current focused element. :Args: - keys_to_send: The keys to send. Modifier keys constants can be found in the 'Keys' class. """ typing = keys_to_typing(keys_to_send) if self._driver.w3c: for key in typing: self.key_down(key) self.key_up(key) else: self._actions.append(lambda: self._driver.execute( Command.SEND_KEYS_TO_ACTIVE_ELEMENT, {'value': typing})) return self
[ "def", "send_keys", "(", "self", ",", "*", "keys_to_send", ")", ":", "typing", "=", "keys_to_typing", "(", "keys_to_send", ")", "if", "self", ".", "_driver", ".", "w3c", ":", "for", "key", "in", "typing", ":", "self", ".", "key_down", "(", "key", ")", "self", ".", "key_up", "(", "key", ")", "else", ":", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "execute", "(", "Command", ".", "SEND_KEYS_TO_ACTIVE_ELEMENT", ",", "{", "'value'", ":", "typing", "}", ")", ")", "return", "self" ]
Sends keys to current focused element. :Args: - keys_to_send: The keys to send. Modifier keys constants can be found in the 'Keys' class.
[ "Sends", "keys", "to", "current", "focused", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L327-L343
21,143
SeleniumHQ/selenium
py/selenium/webdriver/common/action_chains.py
ActionChains.send_keys_to_element
def send_keys_to_element(self, element, *keys_to_send): """ Sends keys to an element. :Args: - element: The element to send keys. - keys_to_send: The keys to send. Modifier keys constants can be found in the 'Keys' class. """ self.click(element) self.send_keys(*keys_to_send) return self
python
def send_keys_to_element(self, element, *keys_to_send): """ Sends keys to an element. :Args: - element: The element to send keys. - keys_to_send: The keys to send. Modifier keys constants can be found in the 'Keys' class. """ self.click(element) self.send_keys(*keys_to_send) return self
[ "def", "send_keys_to_element", "(", "self", ",", "element", ",", "*", "keys_to_send", ")", ":", "self", ".", "click", "(", "element", ")", "self", ".", "send_keys", "(", "*", "keys_to_send", ")", "return", "self" ]
Sends keys to an element. :Args: - element: The element to send keys. - keys_to_send: The keys to send. Modifier keys constants can be found in the 'Keys' class.
[ "Sends", "keys", "to", "an", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/action_chains.py#L345-L356
21,144
SeleniumHQ/selenium
py/selenium/webdriver/ie/options.py
Options.browser_attach_timeout
def browser_attach_timeout(self, value): """ Sets the options Browser Attach Timeout :Args: - value: Timeout in milliseconds """ if not isinstance(value, int): raise ValueError('Browser Attach Timeout must be an integer.') self._options[self.BROWSER_ATTACH_TIMEOUT] = value
python
def browser_attach_timeout(self, value): """ Sets the options Browser Attach Timeout :Args: - value: Timeout in milliseconds """ if not isinstance(value, int): raise ValueError('Browser Attach Timeout must be an integer.') self._options[self.BROWSER_ATTACH_TIMEOUT] = value
[ "def", "browser_attach_timeout", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "int", ")", ":", "raise", "ValueError", "(", "'Browser Attach Timeout must be an integer.'", ")", "self", ".", "_options", "[", "self", ".", "BROWSER_ATTACH_TIMEOUT", "]", "=", "value" ]
Sets the options Browser Attach Timeout :Args: - value: Timeout in milliseconds
[ "Sets", "the", "options", "Browser", "Attach", "Timeout" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/ie/options.py#L65-L75
21,145
SeleniumHQ/selenium
py/selenium/webdriver/ie/options.py
Options.element_scroll_behavior
def element_scroll_behavior(self, value): """ Sets the options Element Scroll Behavior :Args: - value: 0 - Top, 1 - Bottom """ if value not in [ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM]: raise ValueError('Element Scroll Behavior out of range.') self._options[self.ELEMENT_SCROLL_BEHAVIOR] = value
python
def element_scroll_behavior(self, value): """ Sets the options Element Scroll Behavior :Args: - value: 0 - Top, 1 - Bottom """ if value not in [ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM]: raise ValueError('Element Scroll Behavior out of range.') self._options[self.ELEMENT_SCROLL_BEHAVIOR] = value
[ "def", "element_scroll_behavior", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "[", "ElementScrollBehavior", ".", "TOP", ",", "ElementScrollBehavior", ".", "BOTTOM", "]", ":", "raise", "ValueError", "(", "'Element Scroll Behavior out of range.'", ")", "self", ".", "_options", "[", "self", ".", "ELEMENT_SCROLL_BEHAVIOR", "]", "=", "value" ]
Sets the options Element Scroll Behavior :Args: - value: 0 - Top, 1 - Bottom
[ "Sets", "the", "options", "Element", "Scroll", "Behavior" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/ie/options.py#L83-L93
21,146
SeleniumHQ/selenium
py/selenium/webdriver/ie/options.py
Options.file_upload_dialog_timeout
def file_upload_dialog_timeout(self, value): """ Sets the options File Upload Dialog Timeout value :Args: - value: Timeout in milliseconds """ if not isinstance(value, int): raise ValueError('File Upload Dialog Timeout must be an integer.') self._options[self.FILE_UPLOAD_DIALOG_TIMEOUT] = value
python
def file_upload_dialog_timeout(self, value): """ Sets the options File Upload Dialog Timeout value :Args: - value: Timeout in milliseconds """ if not isinstance(value, int): raise ValueError('File Upload Dialog Timeout must be an integer.') self._options[self.FILE_UPLOAD_DIALOG_TIMEOUT] = value
[ "def", "file_upload_dialog_timeout", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "int", ")", ":", "raise", "ValueError", "(", "'File Upload Dialog Timeout must be an integer.'", ")", "self", ".", "_options", "[", "self", ".", "FILE_UPLOAD_DIALOG_TIMEOUT", "]", "=", "value" ]
Sets the options File Upload Dialog Timeout value :Args: - value: Timeout in milliseconds
[ "Sets", "the", "options", "File", "Upload", "Dialog", "Timeout", "value" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/ie/options.py#L117-L127
21,147
SeleniumHQ/selenium
py/selenium/webdriver/ie/options.py
Options.to_capabilities
def to_capabilities(self): """Marshals the IE options to the correct object.""" caps = self._caps opts = self._options.copy() if len(self._arguments) > 0: opts[self.SWITCHES] = ' '.join(self._arguments) if len(self._additional) > 0: opts.update(self._additional) if len(opts) > 0: caps[Options.KEY] = opts return caps
python
def to_capabilities(self): """Marshals the IE options to the correct object.""" caps = self._caps opts = self._options.copy() if len(self._arguments) > 0: opts[self.SWITCHES] = ' '.join(self._arguments) if len(self._additional) > 0: opts.update(self._additional) if len(opts) > 0: caps[Options.KEY] = opts return caps
[ "def", "to_capabilities", "(", "self", ")", ":", "caps", "=", "self", ".", "_caps", "opts", "=", "self", ".", "_options", ".", "copy", "(", ")", "if", "len", "(", "self", ".", "_arguments", ")", ">", "0", ":", "opts", "[", "self", ".", "SWITCHES", "]", "=", "' '", ".", "join", "(", "self", ".", "_arguments", ")", "if", "len", "(", "self", ".", "_additional", ")", ">", "0", ":", "opts", ".", "update", "(", "self", ".", "_additional", ")", "if", "len", "(", "opts", ")", ">", "0", ":", "caps", "[", "Options", ".", "KEY", "]", "=", "opts", "return", "caps" ]
Marshals the IE options to the correct object.
[ "Marshals", "the", "IE", "options", "to", "the", "correct", "object", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/ie/options.py#L321-L334
21,148
SeleniumHQ/selenium
py/selenium/webdriver/chrome/options.py
Options.add_extension
def add_extension(self, extension): """ Adds the path to the extension to a list that will be used to extract it to the ChromeDriver :Args: - extension: path to the \\*.crx file """ if extension: extension_to_add = os.path.abspath(os.path.expanduser(extension)) if os.path.exists(extension_to_add): self._extension_files.append(extension_to_add) else: raise IOError("Path to the extension doesn't exist") else: raise ValueError("argument can not be null")
python
def add_extension(self, extension): """ Adds the path to the extension to a list that will be used to extract it to the ChromeDriver :Args: - extension: path to the \\*.crx file """ if extension: extension_to_add = os.path.abspath(os.path.expanduser(extension)) if os.path.exists(extension_to_add): self._extension_files.append(extension_to_add) else: raise IOError("Path to the extension doesn't exist") else: raise ValueError("argument can not be null")
[ "def", "add_extension", "(", "self", ",", "extension", ")", ":", "if", "extension", ":", "extension_to_add", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "extension", ")", ")", "if", "os", ".", "path", ".", "exists", "(", "extension_to_add", ")", ":", "self", ".", "_extension_files", ".", "append", "(", "extension_to_add", ")", "else", ":", "raise", "IOError", "(", "\"Path to the extension doesn't exist\"", ")", "else", ":", "raise", "ValueError", "(", "\"argument can not be null\"", ")" ]
Adds the path to the extension to a list that will be used to extract it to the ChromeDriver :Args: - extension: path to the \\*.crx file
[ "Adds", "the", "path", "to", "the", "extension", "to", "a", "list", "that", "will", "be", "used", "to", "extract", "it", "to", "the", "ChromeDriver" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/chrome/options.py#L88-L103
21,149
SeleniumHQ/selenium
py/selenium/webdriver/chrome/options.py
Options.to_capabilities
def to_capabilities(self): """ Creates a capabilities with all the options that have been set :Returns: A dictionary with everything """ caps = self._caps chrome_options = self.experimental_options.copy() chrome_options["extensions"] = self.extensions if self.binary_location: chrome_options["binary"] = self.binary_location chrome_options["args"] = self.arguments if self.debugger_address: chrome_options["debuggerAddress"] = self.debugger_address caps[self.KEY] = chrome_options return caps
python
def to_capabilities(self): """ Creates a capabilities with all the options that have been set :Returns: A dictionary with everything """ caps = self._caps chrome_options = self.experimental_options.copy() chrome_options["extensions"] = self.extensions if self.binary_location: chrome_options["binary"] = self.binary_location chrome_options["args"] = self.arguments if self.debugger_address: chrome_options["debuggerAddress"] = self.debugger_address caps[self.KEY] = chrome_options return caps
[ "def", "to_capabilities", "(", "self", ")", ":", "caps", "=", "self", ".", "_caps", "chrome_options", "=", "self", ".", "experimental_options", ".", "copy", "(", ")", "chrome_options", "[", "\"extensions\"", "]", "=", "self", ".", "extensions", "if", "self", ".", "binary_location", ":", "chrome_options", "[", "\"binary\"", "]", "=", "self", ".", "binary_location", "chrome_options", "[", "\"args\"", "]", "=", "self", ".", "arguments", "if", "self", ".", "debugger_address", ":", "chrome_options", "[", "\"debuggerAddress\"", "]", "=", "self", ".", "debugger_address", "caps", "[", "self", ".", "KEY", "]", "=", "chrome_options", "return", "caps" ]
Creates a capabilities with all the options that have been set :Returns: A dictionary with everything
[ "Creates", "a", "capabilities", "with", "all", "the", "options", "that", "have", "been", "set" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/chrome/options.py#L156-L173
21,150
SeleniumHQ/selenium
py/selenium/webdriver/support/expected_conditions.py
_find_element
def _find_element(driver, by): """Looks up an element. Logs and re-raises ``WebDriverException`` if thrown.""" try: return driver.find_element(*by) except NoSuchElementException as e: raise e except WebDriverException as e: raise e
python
def _find_element(driver, by): """Looks up an element. Logs and re-raises ``WebDriverException`` if thrown.""" try: return driver.find_element(*by) except NoSuchElementException as e: raise e except WebDriverException as e: raise e
[ "def", "_find_element", "(", "driver", ",", "by", ")", ":", "try", ":", "return", "driver", ".", "find_element", "(", "*", "by", ")", "except", "NoSuchElementException", "as", "e", ":", "raise", "e", "except", "WebDriverException", "as", "e", ":", "raise", "e" ]
Looks up an element. Logs and re-raises ``WebDriverException`` if thrown.
[ "Looks", "up", "an", "element", ".", "Logs", "and", "re", "-", "raises", "WebDriverException", "if", "thrown", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/expected_conditions.py#L407-L415
21,151
SeleniumHQ/selenium
py/selenium/webdriver/common/alert.py
Alert.text
def text(self): """ Gets the text of the Alert. """ if self.driver.w3c: return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"] else: return self.driver.execute(Command.GET_ALERT_TEXT)["value"]
python
def text(self): """ Gets the text of the Alert. """ if self.driver.w3c: return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"] else: return self.driver.execute(Command.GET_ALERT_TEXT)["value"]
[ "def", "text", "(", "self", ")", ":", "if", "self", ".", "driver", ".", "w3c", ":", "return", "self", ".", "driver", ".", "execute", "(", "Command", ".", "W3C_GET_ALERT_TEXT", ")", "[", "\"value\"", "]", "else", ":", "return", "self", ".", "driver", ".", "execute", "(", "Command", ".", "GET_ALERT_TEXT", ")", "[", "\"value\"", "]" ]
Gets the text of the Alert.
[ "Gets", "the", "text", "of", "the", "Alert", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/alert.py#L62-L69
21,152
SeleniumHQ/selenium
py/selenium/webdriver/common/alert.py
Alert.dismiss
def dismiss(self): """ Dismisses the alert available. """ if self.driver.w3c: self.driver.execute(Command.W3C_DISMISS_ALERT) else: self.driver.execute(Command.DISMISS_ALERT)
python
def dismiss(self): """ Dismisses the alert available. """ if self.driver.w3c: self.driver.execute(Command.W3C_DISMISS_ALERT) else: self.driver.execute(Command.DISMISS_ALERT)
[ "def", "dismiss", "(", "self", ")", ":", "if", "self", ".", "driver", ".", "w3c", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "W3C_DISMISS_ALERT", ")", "else", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "DISMISS_ALERT", ")" ]
Dismisses the alert available.
[ "Dismisses", "the", "alert", "available", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/alert.py#L71-L78
21,153
SeleniumHQ/selenium
py/selenium/webdriver/common/alert.py
Alert.accept
def accept(self): """ Accepts the alert available. Usage:: Alert(driver).accept() # Confirm a alert dialog. """ if self.driver.w3c: self.driver.execute(Command.W3C_ACCEPT_ALERT) else: self.driver.execute(Command.ACCEPT_ALERT)
python
def accept(self): """ Accepts the alert available. Usage:: Alert(driver).accept() # Confirm a alert dialog. """ if self.driver.w3c: self.driver.execute(Command.W3C_ACCEPT_ALERT) else: self.driver.execute(Command.ACCEPT_ALERT)
[ "def", "accept", "(", "self", ")", ":", "if", "self", ".", "driver", ".", "w3c", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "W3C_ACCEPT_ALERT", ")", "else", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "ACCEPT_ALERT", ")" ]
Accepts the alert available. Usage:: Alert(driver).accept() # Confirm a alert dialog.
[ "Accepts", "the", "alert", "available", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/alert.py#L80-L90
21,154
SeleniumHQ/selenium
py/selenium/webdriver/common/alert.py
Alert.send_keys
def send_keys(self, keysToSend): """ Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert. """ if self.driver.w3c: self.driver.execute(Command.W3C_SET_ALERT_VALUE, {'value': keys_to_typing(keysToSend), 'text': keysToSend}) else: self.driver.execute(Command.SET_ALERT_VALUE, {'text': keysToSend})
python
def send_keys(self, keysToSend): """ Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert. """ if self.driver.w3c: self.driver.execute(Command.W3C_SET_ALERT_VALUE, {'value': keys_to_typing(keysToSend), 'text': keysToSend}) else: self.driver.execute(Command.SET_ALERT_VALUE, {'text': keysToSend})
[ "def", "send_keys", "(", "self", ",", "keysToSend", ")", ":", "if", "self", ".", "driver", ".", "w3c", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "W3C_SET_ALERT_VALUE", ",", "{", "'value'", ":", "keys_to_typing", "(", "keysToSend", ")", ",", "'text'", ":", "keysToSend", "}", ")", "else", ":", "self", ".", "driver", ".", "execute", "(", "Command", ".", "SET_ALERT_VALUE", ",", "{", "'text'", ":", "keysToSend", "}", ")" ]
Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert.
[ "Send", "Keys", "to", "the", "Alert", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/alert.py#L92-L105
21,155
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_profile.py
FirefoxProfile.port
def port(self, port): """ Sets the port that WebDriver will be running on """ if not isinstance(port, int): raise WebDriverException("Port needs to be an integer") try: port = int(port) if port < 1 or port > 65535: raise WebDriverException("Port number must be in the range 1..65535") except (ValueError, TypeError): raise WebDriverException("Port needs to be an integer") self._port = port self.set_preference("webdriver_firefox_port", self._port)
python
def port(self, port): """ Sets the port that WebDriver will be running on """ if not isinstance(port, int): raise WebDriverException("Port needs to be an integer") try: port = int(port) if port < 1 or port > 65535: raise WebDriverException("Port number must be in the range 1..65535") except (ValueError, TypeError): raise WebDriverException("Port needs to be an integer") self._port = port self.set_preference("webdriver_firefox_port", self._port)
[ "def", "port", "(", "self", ",", "port", ")", ":", "if", "not", "isinstance", "(", "port", ",", "int", ")", ":", "raise", "WebDriverException", "(", "\"Port needs to be an integer\"", ")", "try", ":", "port", "=", "int", "(", "port", ")", "if", "port", "<", "1", "or", "port", ">", "65535", ":", "raise", "WebDriverException", "(", "\"Port number must be in the range 1..65535\"", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "raise", "WebDriverException", "(", "\"Port needs to be an integer\"", ")", "self", ".", "_port", "=", "port", "self", ".", "set_preference", "(", "\"webdriver_firefox_port\"", ",", "self", ".", "_port", ")" ]
Sets the port that WebDriver will be running on
[ "Sets", "the", "port", "that", "WebDriver", "will", "be", "running", "on" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_profile.py#L119-L132
21,156
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_profile.py
FirefoxProfile.encoded
def encoded(self): """ A zipped, base64 encoded string of profile directory for use with remote WebDriver JSON wire protocol """ self.update_preferences() fp = BytesIO() zipped = zipfile.ZipFile(fp, 'w', zipfile.ZIP_DEFLATED) path_root = len(self.path) + 1 # account for trailing slash for base, dirs, files in os.walk(self.path): for fyle in files: filename = os.path.join(base, fyle) zipped.write(filename, filename[path_root:]) zipped.close() return base64.b64encode(fp.getvalue()).decode('UTF-8')
python
def encoded(self): """ A zipped, base64 encoded string of profile directory for use with remote WebDriver JSON wire protocol """ self.update_preferences() fp = BytesIO() zipped = zipfile.ZipFile(fp, 'w', zipfile.ZIP_DEFLATED) path_root = len(self.path) + 1 # account for trailing slash for base, dirs, files in os.walk(self.path): for fyle in files: filename = os.path.join(base, fyle) zipped.write(filename, filename[path_root:]) zipped.close() return base64.b64encode(fp.getvalue()).decode('UTF-8')
[ "def", "encoded", "(", "self", ")", ":", "self", ".", "update_preferences", "(", ")", "fp", "=", "BytesIO", "(", ")", "zipped", "=", "zipfile", ".", "ZipFile", "(", "fp", ",", "'w'", ",", "zipfile", ".", "ZIP_DEFLATED", ")", "path_root", "=", "len", "(", "self", ".", "path", ")", "+", "1", "# account for trailing slash", "for", "base", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "path", ")", ":", "for", "fyle", "in", "files", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "base", ",", "fyle", ")", "zipped", ".", "write", "(", "filename", ",", "filename", "[", "path_root", ":", "]", ")", "zipped", ".", "close", "(", ")", "return", "base64", ".", "b64encode", "(", "fp", ".", "getvalue", "(", ")", ")", ".", "decode", "(", "'UTF-8'", ")" ]
A zipped, base64 encoded string of profile directory for use with remote WebDriver JSON wire protocol
[ "A", "zipped", "base64", "encoded", "string", "of", "profile", "directory", "for", "use", "with", "remote", "WebDriver", "JSON", "wire", "protocol" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_profile.py#L156-L170
21,157
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_profile.py
FirefoxProfile._write_user_prefs
def _write_user_prefs(self, user_prefs): """ writes the current user prefs dictionary to disk """ with open(self.userPrefs, "w") as f: for key, value in user_prefs.items(): f.write('user_pref("%s", %s);\n' % (key, json.dumps(value)))
python
def _write_user_prefs(self, user_prefs): """ writes the current user prefs dictionary to disk """ with open(self.userPrefs, "w") as f: for key, value in user_prefs.items(): f.write('user_pref("%s", %s);\n' % (key, json.dumps(value)))
[ "def", "_write_user_prefs", "(", "self", ",", "user_prefs", ")", ":", "with", "open", "(", "self", ".", "userPrefs", ",", "\"w\"", ")", "as", "f", ":", "for", "key", ",", "value", "in", "user_prefs", ".", "items", "(", ")", ":", "f", ".", "write", "(", "'user_pref(\"%s\", %s);\\n'", "%", "(", "key", ",", "json", ".", "dumps", "(", "value", ")", ")", ")" ]
writes the current user prefs dictionary to disk
[ "writes", "the", "current", "user", "prefs", "dictionary", "to", "disk" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_profile.py#L178-L184
21,158
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.submit
def submit(self): """Submits a form.""" if self._w3c: form = self.find_element(By.XPATH, "./ancestor-or-self::form") self._parent.execute_script( "var e = arguments[0].ownerDocument.createEvent('Event');" "e.initEvent('submit', true, true);" "if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }", form) else: self._execute(Command.SUBMIT_ELEMENT)
python
def submit(self): """Submits a form.""" if self._w3c: form = self.find_element(By.XPATH, "./ancestor-or-self::form") self._parent.execute_script( "var e = arguments[0].ownerDocument.createEvent('Event');" "e.initEvent('submit', true, true);" "if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }", form) else: self._execute(Command.SUBMIT_ELEMENT)
[ "def", "submit", "(", "self", ")", ":", "if", "self", ".", "_w3c", ":", "form", "=", "self", ".", "find_element", "(", "By", ".", "XPATH", ",", "\"./ancestor-or-self::form\"", ")", "self", ".", "_parent", ".", "execute_script", "(", "\"var e = arguments[0].ownerDocument.createEvent('Event');\"", "\"e.initEvent('submit', true, true);\"", "\"if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }\"", ",", "form", ")", "else", ":", "self", ".", "_execute", "(", "Command", ".", "SUBMIT_ELEMENT", ")" ]
Submits a form.
[ "Submits", "a", "form", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L82-L91
21,159
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.get_property
def get_property(self, name): """ Gets the given property of the element. :Args: - name - Name of the property to retrieve. :Usage: :: text_length = target_element.get_property("text_length") """ try: return self._execute(Command.GET_ELEMENT_PROPERTY, {"name": name})["value"] except WebDriverException: # if we hit an end point that doesnt understand getElementProperty lets fake it return self.parent.execute_script('return arguments[0][arguments[1]]', self, name)
python
def get_property(self, name): """ Gets the given property of the element. :Args: - name - Name of the property to retrieve. :Usage: :: text_length = target_element.get_property("text_length") """ try: return self._execute(Command.GET_ELEMENT_PROPERTY, {"name": name})["value"] except WebDriverException: # if we hit an end point that doesnt understand getElementProperty lets fake it return self.parent.execute_script('return arguments[0][arguments[1]]', self, name)
[ "def", "get_property", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_PROPERTY", ",", "{", "\"name\"", ":", "name", "}", ")", "[", "\"value\"", "]", "except", "WebDriverException", ":", "# if we hit an end point that doesnt understand getElementProperty lets fake it", "return", "self", ".", "parent", ".", "execute_script", "(", "'return arguments[0][arguments[1]]'", ",", "self", ",", "name", ")" ]
Gets the given property of the element. :Args: - name - Name of the property to retrieve. :Usage: :: text_length = target_element.get_property("text_length")
[ "Gets", "the", "given", "property", "of", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L97-L113
21,160
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.get_attribute
def get_attribute(self, name): """Gets the given attribute or property of the element. This method will first try to return the value of a property with the given name. If a property with that name doesn't exist, it returns the value of the attribute with the same name. If there's no attribute with that name, ``None`` is returned. Values which are considered truthy, that is equals "true" or "false", are returned as booleans. All other non-``None`` values are returned as strings. For attributes or properties which do not exist, ``None`` is returned. :Args: - name - Name of the attribute/property to retrieve. Example:: # Check if the "active" CSS class is applied to an element. is_active = "active" in target_element.get_attribute("class") """ attributeValue = '' if self._w3c: attributeValue = self.parent.execute_script( "return (%s).apply(null, arguments);" % getAttribute_js, self, name) else: resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name}) attributeValue = resp.get('value') if attributeValue is not None: if name != 'value' and attributeValue.lower() in ('true', 'false'): attributeValue = attributeValue.lower() return attributeValue
python
def get_attribute(self, name): """Gets the given attribute or property of the element. This method will first try to return the value of a property with the given name. If a property with that name doesn't exist, it returns the value of the attribute with the same name. If there's no attribute with that name, ``None`` is returned. Values which are considered truthy, that is equals "true" or "false", are returned as booleans. All other non-``None`` values are returned as strings. For attributes or properties which do not exist, ``None`` is returned. :Args: - name - Name of the attribute/property to retrieve. Example:: # Check if the "active" CSS class is applied to an element. is_active = "active" in target_element.get_attribute("class") """ attributeValue = '' if self._w3c: attributeValue = self.parent.execute_script( "return (%s).apply(null, arguments);" % getAttribute_js, self, name) else: resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name}) attributeValue = resp.get('value') if attributeValue is not None: if name != 'value' and attributeValue.lower() in ('true', 'false'): attributeValue = attributeValue.lower() return attributeValue
[ "def", "get_attribute", "(", "self", ",", "name", ")", ":", "attributeValue", "=", "''", "if", "self", ".", "_w3c", ":", "attributeValue", "=", "self", ".", "parent", ".", "execute_script", "(", "\"return (%s).apply(null, arguments);\"", "%", "getAttribute_js", ",", "self", ",", "name", ")", "else", ":", "resp", "=", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_ATTRIBUTE", ",", "{", "'name'", ":", "name", "}", ")", "attributeValue", "=", "resp", ".", "get", "(", "'value'", ")", "if", "attributeValue", "is", "not", "None", ":", "if", "name", "!=", "'value'", "and", "attributeValue", ".", "lower", "(", ")", "in", "(", "'true'", ",", "'false'", ")", ":", "attributeValue", "=", "attributeValue", ".", "lower", "(", ")", "return", "attributeValue" ]
Gets the given attribute or property of the element. This method will first try to return the value of a property with the given name. If a property with that name doesn't exist, it returns the value of the attribute with the same name. If there's no attribute with that name, ``None`` is returned. Values which are considered truthy, that is equals "true" or "false", are returned as booleans. All other non-``None`` values are returned as strings. For attributes or properties which do not exist, ``None`` is returned. :Args: - name - Name of the attribute/property to retrieve. Example:: # Check if the "active" CSS class is applied to an element. is_active = "active" in target_element.get_attribute("class")
[ "Gets", "the", "given", "attribute", "or", "property", "of", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L115-L149
21,161
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.send_keys
def send_keys(self, *value): """Simulates typing into the element. :Args: - value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path. Use this to send simple key events or to fill out form fields:: form_textfield = driver.find_element_by_name('username') form_textfield.send_keys("admin") This can also be used to set file inputs. :: file_input = driver.find_element_by_name('profilePic') file_input.send_keys("path/to/profilepic.gif") # Generally it's better to wrap the file path in one of the methods # in os.path to return the actual path to support cross OS testing. # file_input.send_keys(os.path.abspath("path/to/profilepic.gif")) """ # transfer file to another machine only if remote driver is used # the same behaviour as for java binding if self.parent._is_remote: local_file = self.parent.file_detector.is_local_file(*value) if local_file is not None: value = self._upload(local_file) self._execute(Command.SEND_KEYS_TO_ELEMENT, {'text': "".join(keys_to_typing(value)), 'value': keys_to_typing(value)})
python
def send_keys(self, *value): """Simulates typing into the element. :Args: - value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path. Use this to send simple key events or to fill out form fields:: form_textfield = driver.find_element_by_name('username') form_textfield.send_keys("admin") This can also be used to set file inputs. :: file_input = driver.find_element_by_name('profilePic') file_input.send_keys("path/to/profilepic.gif") # Generally it's better to wrap the file path in one of the methods # in os.path to return the actual path to support cross OS testing. # file_input.send_keys(os.path.abspath("path/to/profilepic.gif")) """ # transfer file to another machine only if remote driver is used # the same behaviour as for java binding if self.parent._is_remote: local_file = self.parent.file_detector.is_local_file(*value) if local_file is not None: value = self._upload(local_file) self._execute(Command.SEND_KEYS_TO_ELEMENT, {'text': "".join(keys_to_typing(value)), 'value': keys_to_typing(value)})
[ "def", "send_keys", "(", "self", ",", "*", "value", ")", ":", "# transfer file to another machine only if remote driver is used", "# the same behaviour as for java binding", "if", "self", ".", "parent", ".", "_is_remote", ":", "local_file", "=", "self", ".", "parent", ".", "file_detector", ".", "is_local_file", "(", "*", "value", ")", "if", "local_file", "is", "not", "None", ":", "value", "=", "self", ".", "_upload", "(", "local_file", ")", "self", ".", "_execute", "(", "Command", ".", "SEND_KEYS_TO_ELEMENT", ",", "{", "'text'", ":", "\"\"", ".", "join", "(", "keys_to_typing", "(", "value", ")", ")", ",", "'value'", ":", "keys_to_typing", "(", "value", ")", "}", ")" ]
Simulates typing into the element. :Args: - value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path. Use this to send simple key events or to fill out form fields:: form_textfield = driver.find_element_by_name('username') form_textfield.send_keys("admin") This can also be used to set file inputs. :: file_input = driver.find_element_by_name('profilePic') file_input.send_keys("path/to/profilepic.gif") # Generally it's better to wrap the file path in one of the methods # in os.path to return the actual path to support cross OS testing. # file_input.send_keys(os.path.abspath("path/to/profilepic.gif"))
[ "Simulates", "typing", "into", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L480-L512
21,162
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.is_displayed
def is_displayed(self): """Whether the element is visible to a user.""" # Only go into this conditional for browsers that don't use the atom themselves if self._w3c: return self.parent.execute_script( "return (%s).apply(null, arguments);" % isDisplayed_js, self) else: return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']
python
def is_displayed(self): """Whether the element is visible to a user.""" # Only go into this conditional for browsers that don't use the atom themselves if self._w3c: return self.parent.execute_script( "return (%s).apply(null, arguments);" % isDisplayed_js, self) else: return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']
[ "def", "is_displayed", "(", "self", ")", ":", "# Only go into this conditional for browsers that don't use the atom themselves", "if", "self", ".", "_w3c", ":", "return", "self", ".", "parent", ".", "execute_script", "(", "\"return (%s).apply(null, arguments);\"", "%", "isDisplayed_js", ",", "self", ")", "else", ":", "return", "self", ".", "_execute", "(", "Command", ".", "IS_ELEMENT_DISPLAYED", ")", "[", "'value'", "]" ]
Whether the element is visible to a user.
[ "Whether", "the", "element", "is", "visible", "to", "a", "user", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L515-L523
21,163
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.location_once_scrolled_into_view
def location_once_scrolled_into_view(self): """THIS PROPERTY MAY CHANGE WITHOUT WARNING. Use this to discover where on the screen an element is so that we can click it. This method should cause the element to be scrolled into view. Returns the top lefthand corner location on the screen, or ``None`` if the element is not visible. """ if self._w3c: old_loc = self._execute(Command.W3C_EXECUTE_SCRIPT, { 'script': "arguments[0].scrollIntoView(true); return arguments[0].getBoundingClientRect()", 'args': [self]})['value'] return {"x": round(old_loc['x']), "y": round(old_loc['y'])} else: return self._execute(Command.GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW)['value']
python
def location_once_scrolled_into_view(self): """THIS PROPERTY MAY CHANGE WITHOUT WARNING. Use this to discover where on the screen an element is so that we can click it. This method should cause the element to be scrolled into view. Returns the top lefthand corner location on the screen, or ``None`` if the element is not visible. """ if self._w3c: old_loc = self._execute(Command.W3C_EXECUTE_SCRIPT, { 'script': "arguments[0].scrollIntoView(true); return arguments[0].getBoundingClientRect()", 'args': [self]})['value'] return {"x": round(old_loc['x']), "y": round(old_loc['y'])} else: return self._execute(Command.GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW)['value']
[ "def", "location_once_scrolled_into_view", "(", "self", ")", ":", "if", "self", ".", "_w3c", ":", "old_loc", "=", "self", ".", "_execute", "(", "Command", ".", "W3C_EXECUTE_SCRIPT", ",", "{", "'script'", ":", "\"arguments[0].scrollIntoView(true); return arguments[0].getBoundingClientRect()\"", ",", "'args'", ":", "[", "self", "]", "}", ")", "[", "'value'", "]", "return", "{", "\"x\"", ":", "round", "(", "old_loc", "[", "'x'", "]", ")", ",", "\"y\"", ":", "round", "(", "old_loc", "[", "'y'", "]", ")", "}", "else", ":", "return", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW", ")", "[", "'value'", "]" ]
THIS PROPERTY MAY CHANGE WITHOUT WARNING. Use this to discover where on the screen an element is so that we can click it. This method should cause the element to be scrolled into view. Returns the top lefthand corner location on the screen, or ``None`` if the element is not visible.
[ "THIS", "PROPERTY", "MAY", "CHANGE", "WITHOUT", "WARNING", ".", "Use", "this", "to", "discover", "where", "on", "the", "screen", "an", "element", "is", "so", "that", "we", "can", "click", "it", ".", "This", "method", "should", "cause", "the", "element", "to", "be", "scrolled", "into", "view", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L526-L542
21,164
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.size
def size(self): """The size of the element.""" size = {} if self._w3c: size = self._execute(Command.GET_ELEMENT_RECT)['value'] else: size = self._execute(Command.GET_ELEMENT_SIZE)['value'] new_size = {"height": size["height"], "width": size["width"]} return new_size
python
def size(self): """The size of the element.""" size = {} if self._w3c: size = self._execute(Command.GET_ELEMENT_RECT)['value'] else: size = self._execute(Command.GET_ELEMENT_SIZE)['value'] new_size = {"height": size["height"], "width": size["width"]} return new_size
[ "def", "size", "(", "self", ")", ":", "size", "=", "{", "}", "if", "self", ".", "_w3c", ":", "size", "=", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_RECT", ")", "[", "'value'", "]", "else", ":", "size", "=", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_SIZE", ")", "[", "'value'", "]", "new_size", "=", "{", "\"height\"", ":", "size", "[", "\"height\"", "]", ",", "\"width\"", ":", "size", "[", "\"width\"", "]", "}", "return", "new_size" ]
The size of the element.
[ "The", "size", "of", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L545-L554
21,165
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.location
def location(self): """The location of the element in the renderable canvas.""" if self._w3c: old_loc = self._execute(Command.GET_ELEMENT_RECT)['value'] else: old_loc = self._execute(Command.GET_ELEMENT_LOCATION)['value'] new_loc = {"x": round(old_loc['x']), "y": round(old_loc['y'])} return new_loc
python
def location(self): """The location of the element in the renderable canvas.""" if self._w3c: old_loc = self._execute(Command.GET_ELEMENT_RECT)['value'] else: old_loc = self._execute(Command.GET_ELEMENT_LOCATION)['value'] new_loc = {"x": round(old_loc['x']), "y": round(old_loc['y'])} return new_loc
[ "def", "location", "(", "self", ")", ":", "if", "self", ".", "_w3c", ":", "old_loc", "=", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_RECT", ")", "[", "'value'", "]", "else", ":", "old_loc", "=", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_LOCATION", ")", "[", "'value'", "]", "new_loc", "=", "{", "\"x\"", ":", "round", "(", "old_loc", "[", "'x'", "]", ")", ",", "\"y\"", ":", "round", "(", "old_loc", "[", "'y'", "]", ")", "}", "return", "new_loc" ]
The location of the element in the renderable canvas.
[ "The", "location", "of", "the", "element", "in", "the", "renderable", "canvas", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L562-L570
21,166
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.rect
def rect(self): """A dictionary with the size and location of the element.""" if self._w3c: return self._execute(Command.GET_ELEMENT_RECT)['value'] else: rect = self.size.copy() rect.update(self.location) return rect
python
def rect(self): """A dictionary with the size and location of the element.""" if self._w3c: return self._execute(Command.GET_ELEMENT_RECT)['value'] else: rect = self.size.copy() rect.update(self.location) return rect
[ "def", "rect", "(", "self", ")", ":", "if", "self", ".", "_w3c", ":", "return", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_RECT", ")", "[", "'value'", "]", "else", ":", "rect", "=", "self", ".", "size", ".", "copy", "(", ")", "rect", ".", "update", "(", "self", ".", "location", ")", "return", "rect" ]
A dictionary with the size and location of the element.
[ "A", "dictionary", "with", "the", "size", "and", "location", "of", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L573-L580
21,167
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement.screenshot
def screenshot(self, filename): """ Saves a screenshot of the current element to a PNG image file. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. This should end with a `.png` extension. :Usage: :: element.screenshot('/Screenshots/foo.png') """ if not filename.lower().endswith('.png'): warnings.warn("name used for saved screenshot does not match file " "type. It should end with a `.png` extension", UserWarning) png = self.screenshot_as_png try: with open(filename, 'wb') as f: f.write(png) except IOError: return False finally: del png return True
python
def screenshot(self, filename): """ Saves a screenshot of the current element to a PNG image file. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. This should end with a `.png` extension. :Usage: :: element.screenshot('/Screenshots/foo.png') """ if not filename.lower().endswith('.png'): warnings.warn("name used for saved screenshot does not match file " "type. It should end with a `.png` extension", UserWarning) png = self.screenshot_as_png try: with open(filename, 'wb') as f: f.write(png) except IOError: return False finally: del png return True
[ "def", "screenshot", "(", "self", ",", "filename", ")", ":", "if", "not", "filename", ".", "lower", "(", ")", ".", "endswith", "(", "'.png'", ")", ":", "warnings", ".", "warn", "(", "\"name used for saved screenshot does not match file \"", "\"type. It should end with a `.png` extension\"", ",", "UserWarning", ")", "png", "=", "self", ".", "screenshot_as_png", "try", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "png", ")", "except", "IOError", ":", "return", "False", "finally", ":", "del", "png", "return", "True" ]
Saves a screenshot of the current element to a PNG image file. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. This should end with a `.png` extension. :Usage: :: element.screenshot('/Screenshots/foo.png')
[ "Saves", "a", "screenshot", "of", "the", "current", "element", "to", "a", "PNG", "image", "file", ".", "Returns", "False", "if", "there", "is", "any", "IOError", "else", "returns", "True", ".", "Use", "full", "paths", "in", "your", "filename", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L606-L632
21,168
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
WebElement._execute
def _execute(self, command, params=None): """Executes a command against the underlying HTML element. Args: command: The name of the command to _execute as a string. params: A dictionary of named parameters to send with the command. Returns: The command's JSON response loaded into a dictionary object. """ if not params: params = {} params['id'] = self._id return self._parent.execute(command, params)
python
def _execute(self, command, params=None): """Executes a command against the underlying HTML element. Args: command: The name of the command to _execute as a string. params: A dictionary of named parameters to send with the command. Returns: The command's JSON response loaded into a dictionary object. """ if not params: params = {} params['id'] = self._id return self._parent.execute(command, params)
[ "def", "_execute", "(", "self", ",", "command", ",", "params", "=", "None", ")", ":", "if", "not", "params", ":", "params", "=", "{", "}", "params", "[", "'id'", "]", "=", "self", ".", "_id", "return", "self", ".", "_parent", ".", "execute", "(", "command", ",", "params", ")" ]
Executes a command against the underlying HTML element. Args: command: The name of the command to _execute as a string. params: A dictionary of named parameters to send with the command. Returns: The command's JSON response loaded into a dictionary object.
[ "Executes", "a", "command", "against", "the", "underlying", "HTML", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L659-L672
21,169
SeleniumHQ/selenium
py/selenium/webdriver/webkitgtk/webdriver.py
WebDriver.quit
def quit(self): """ Closes the browser and shuts down the WebKitGTKDriver executable that is started when starting the WebKitGTKDriver """ try: RemoteWebDriver.quit(self) except http_client.BadStatusLine: pass finally: self.service.stop()
python
def quit(self): """ Closes the browser and shuts down the WebKitGTKDriver executable that is started when starting the WebKitGTKDriver """ try: RemoteWebDriver.quit(self) except http_client.BadStatusLine: pass finally: self.service.stop()
[ "def", "quit", "(", "self", ")", ":", "try", ":", "RemoteWebDriver", ".", "quit", "(", "self", ")", "except", "http_client", ".", "BadStatusLine", ":", "pass", "finally", ":", "self", ".", "service", ".", "stop", "(", ")" ]
Closes the browser and shuts down the WebKitGTKDriver executable that is started when starting the WebKitGTKDriver
[ "Closes", "the", "browser", "and", "shuts", "down", "the", "WebKitGTKDriver", "executable", "that", "is", "started", "when", "starting", "the", "WebKitGTKDriver" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/webkitgtk/webdriver.py#L68-L78
21,170
SeleniumHQ/selenium
py/selenium/webdriver/common/service.py
Service.start
def start(self): """ Starts the Service. :Exceptions: - WebDriverException : Raised either when it can't start the service or when it can't connect to the service """ try: cmd = [self.path] cmd.extend(self.command_line_args()) self.process = subprocess.Popen(cmd, env=self.env, close_fds=platform.system() != 'Windows', stdout=self.log_file, stderr=self.log_file, stdin=PIPE) except TypeError: raise except OSError as err: if err.errno == errno.ENOENT: raise WebDriverException( "'%s' executable needs to be in PATH. %s" % ( os.path.basename(self.path), self.start_error_message) ) elif err.errno == errno.EACCES: raise WebDriverException( "'%s' executable may have wrong permissions. %s" % ( os.path.basename(self.path), self.start_error_message) ) else: raise except Exception as e: raise WebDriverException( "The executable %s needs to be available in the path. %s\n%s" % (os.path.basename(self.path), self.start_error_message, str(e))) count = 0 while True: self.assert_process_still_running() if self.is_connectable(): break count += 1 time.sleep(1) if count == 30: raise WebDriverException("Can not connect to the Service %s" % self.path)
python
def start(self): """ Starts the Service. :Exceptions: - WebDriverException : Raised either when it can't start the service or when it can't connect to the service """ try: cmd = [self.path] cmd.extend(self.command_line_args()) self.process = subprocess.Popen(cmd, env=self.env, close_fds=platform.system() != 'Windows', stdout=self.log_file, stderr=self.log_file, stdin=PIPE) except TypeError: raise except OSError as err: if err.errno == errno.ENOENT: raise WebDriverException( "'%s' executable needs to be in PATH. %s" % ( os.path.basename(self.path), self.start_error_message) ) elif err.errno == errno.EACCES: raise WebDriverException( "'%s' executable may have wrong permissions. %s" % ( os.path.basename(self.path), self.start_error_message) ) else: raise except Exception as e: raise WebDriverException( "The executable %s needs to be available in the path. %s\n%s" % (os.path.basename(self.path), self.start_error_message, str(e))) count = 0 while True: self.assert_process_still_running() if self.is_connectable(): break count += 1 time.sleep(1) if count == 30: raise WebDriverException("Can not connect to the Service %s" % self.path)
[ "def", "start", "(", "self", ")", ":", "try", ":", "cmd", "=", "[", "self", ".", "path", "]", "cmd", ".", "extend", "(", "self", ".", "command_line_args", "(", ")", ")", "self", ".", "process", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "env", "=", "self", ".", "env", ",", "close_fds", "=", "platform", ".", "system", "(", ")", "!=", "'Windows'", ",", "stdout", "=", "self", ".", "log_file", ",", "stderr", "=", "self", ".", "log_file", ",", "stdin", "=", "PIPE", ")", "except", "TypeError", ":", "raise", "except", "OSError", "as", "err", ":", "if", "err", ".", "errno", "==", "errno", ".", "ENOENT", ":", "raise", "WebDriverException", "(", "\"'%s' executable needs to be in PATH. %s\"", "%", "(", "os", ".", "path", ".", "basename", "(", "self", ".", "path", ")", ",", "self", ".", "start_error_message", ")", ")", "elif", "err", ".", "errno", "==", "errno", ".", "EACCES", ":", "raise", "WebDriverException", "(", "\"'%s' executable may have wrong permissions. %s\"", "%", "(", "os", ".", "path", ".", "basename", "(", "self", ".", "path", ")", ",", "self", ".", "start_error_message", ")", ")", "else", ":", "raise", "except", "Exception", "as", "e", ":", "raise", "WebDriverException", "(", "\"The executable %s needs to be available in the path. %s\\n%s\"", "%", "(", "os", ".", "path", ".", "basename", "(", "self", ".", "path", ")", ",", "self", ".", "start_error_message", ",", "str", "(", "e", ")", ")", ")", "count", "=", "0", "while", "True", ":", "self", ".", "assert_process_still_running", "(", ")", "if", "self", ".", "is_connectable", "(", ")", ":", "break", "count", "+=", "1", "time", ".", "sleep", "(", "1", ")", "if", "count", "==", "30", ":", "raise", "WebDriverException", "(", "\"Can not connect to the Service %s\"", "%", "self", ".", "path", ")" ]
Starts the Service. :Exceptions: - WebDriverException : Raised either when it can't start the service or when it can't connect to the service
[ "Starts", "the", "Service", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/service.py#L61-L104
21,171
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_binary.py
FirefoxBinary.launch_browser
def launch_browser(self, profile, timeout=30): """Launches the browser for the given profile name. It is assumed the profile already exists. """ self.profile = profile self._start_from_profile_path(self.profile.path) self._wait_until_connectable(timeout=timeout)
python
def launch_browser(self, profile, timeout=30): """Launches the browser for the given profile name. It is assumed the profile already exists. """ self.profile = profile self._start_from_profile_path(self.profile.path) self._wait_until_connectable(timeout=timeout)
[ "def", "launch_browser", "(", "self", ",", "profile", ",", "timeout", "=", "30", ")", ":", "self", ".", "profile", "=", "profile", "self", ".", "_start_from_profile_path", "(", "self", ".", "profile", ".", "path", ")", "self", ".", "_wait_until_connectable", "(", "timeout", "=", "timeout", ")" ]
Launches the browser for the given profile name. It is assumed the profile already exists.
[ "Launches", "the", "browser", "for", "the", "given", "profile", "name", ".", "It", "is", "assumed", "the", "profile", "already", "exists", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_binary.py#L66-L73
21,172
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_binary.py
FirefoxBinary.kill
def kill(self): """Kill the browser. This is useful when the browser is stuck. """ if self.process: self.process.kill() self.process.wait()
python
def kill(self): """Kill the browser. This is useful when the browser is stuck. """ if self.process: self.process.kill() self.process.wait()
[ "def", "kill", "(", "self", ")", ":", "if", "self", ".", "process", ":", "self", ".", "process", ".", "kill", "(", ")", "self", ".", "process", ".", "wait", "(", ")" ]
Kill the browser. This is useful when the browser is stuck.
[ "Kill", "the", "browser", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_binary.py#L75-L82
21,173
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_binary.py
FirefoxBinary._wait_until_connectable
def _wait_until_connectable(self, timeout=30): """Blocks until the extension is connectable in the firefox.""" count = 0 while not utils.is_connectable(self.profile.port): if self.process.poll() is not None: # Browser has exited raise WebDriverException( "The browser appears to have exited " "before we could connect. If you specified a log_file in " "the FirefoxBinary constructor, check it for details.") if count >= timeout: self.kill() raise WebDriverException( "Can't load the profile. Possible firefox version mismatch. " "You must use GeckoDriver instead for Firefox 48+. Profile " "Dir: %s If you specified a log_file in the " "FirefoxBinary constructor, check it for details." % (self.profile.path)) count += 1 time.sleep(1) return True
python
def _wait_until_connectable(self, timeout=30): """Blocks until the extension is connectable in the firefox.""" count = 0 while not utils.is_connectable(self.profile.port): if self.process.poll() is not None: # Browser has exited raise WebDriverException( "The browser appears to have exited " "before we could connect. If you specified a log_file in " "the FirefoxBinary constructor, check it for details.") if count >= timeout: self.kill() raise WebDriverException( "Can't load the profile. Possible firefox version mismatch. " "You must use GeckoDriver instead for Firefox 48+. Profile " "Dir: %s If you specified a log_file in the " "FirefoxBinary constructor, check it for details." % (self.profile.path)) count += 1 time.sleep(1) return True
[ "def", "_wait_until_connectable", "(", "self", ",", "timeout", "=", "30", ")", ":", "count", "=", "0", "while", "not", "utils", ".", "is_connectable", "(", "self", ".", "profile", ".", "port", ")", ":", "if", "self", ".", "process", ".", "poll", "(", ")", "is", "not", "None", ":", "# Browser has exited", "raise", "WebDriverException", "(", "\"The browser appears to have exited \"", "\"before we could connect. If you specified a log_file in \"", "\"the FirefoxBinary constructor, check it for details.\"", ")", "if", "count", ">=", "timeout", ":", "self", ".", "kill", "(", ")", "raise", "WebDriverException", "(", "\"Can't load the profile. Possible firefox version mismatch. \"", "\"You must use GeckoDriver instead for Firefox 48+. Profile \"", "\"Dir: %s If you specified a log_file in the \"", "\"FirefoxBinary constructor, check it for details.\"", "%", "(", "self", ".", "profile", ".", "path", ")", ")", "count", "+=", "1", "time", ".", "sleep", "(", "1", ")", "return", "True" ]
Blocks until the extension is connectable in the firefox.
[ "Blocks", "until", "the", "extension", "is", "connectable", "in", "the", "firefox", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_binary.py#L97-L117
21,174
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_binary.py
FirefoxBinary._get_firefox_start_cmd
def _get_firefox_start_cmd(self): """Return the command to start firefox.""" start_cmd = "" if platform.system() == "Darwin": start_cmd = "/Applications/Firefox.app/Contents/MacOS/firefox-bin" # fallback to homebrew installation for mac users if not os.path.exists(start_cmd): start_cmd = os.path.expanduser("~") + start_cmd elif platform.system() == "Windows": start_cmd = (self._find_exe_in_registry() or self._default_windows_location()) elif platform.system() == 'Java' and os._name == 'nt': start_cmd = self._default_windows_location() else: for ffname in ["firefox", "iceweasel"]: start_cmd = self.which(ffname) if start_cmd is not None: break else: # couldn't find firefox on the system path raise RuntimeError( "Could not find firefox in your system PATH." + " Please specify the firefox binary location or install firefox") return start_cmd
python
def _get_firefox_start_cmd(self): """Return the command to start firefox.""" start_cmd = "" if platform.system() == "Darwin": start_cmd = "/Applications/Firefox.app/Contents/MacOS/firefox-bin" # fallback to homebrew installation for mac users if not os.path.exists(start_cmd): start_cmd = os.path.expanduser("~") + start_cmd elif platform.system() == "Windows": start_cmd = (self._find_exe_in_registry() or self._default_windows_location()) elif platform.system() == 'Java' and os._name == 'nt': start_cmd = self._default_windows_location() else: for ffname in ["firefox", "iceweasel"]: start_cmd = self.which(ffname) if start_cmd is not None: break else: # couldn't find firefox on the system path raise RuntimeError( "Could not find firefox in your system PATH." + " Please specify the firefox binary location or install firefox") return start_cmd
[ "def", "_get_firefox_start_cmd", "(", "self", ")", ":", "start_cmd", "=", "\"\"", "if", "platform", ".", "system", "(", ")", "==", "\"Darwin\"", ":", "start_cmd", "=", "\"/Applications/Firefox.app/Contents/MacOS/firefox-bin\"", "# fallback to homebrew installation for mac users", "if", "not", "os", ".", "path", ".", "exists", "(", "start_cmd", ")", ":", "start_cmd", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "+", "start_cmd", "elif", "platform", ".", "system", "(", ")", "==", "\"Windows\"", ":", "start_cmd", "=", "(", "self", ".", "_find_exe_in_registry", "(", ")", "or", "self", ".", "_default_windows_location", "(", ")", ")", "elif", "platform", ".", "system", "(", ")", "==", "'Java'", "and", "os", ".", "_name", "==", "'nt'", ":", "start_cmd", "=", "self", ".", "_default_windows_location", "(", ")", "else", ":", "for", "ffname", "in", "[", "\"firefox\"", ",", "\"iceweasel\"", "]", ":", "start_cmd", "=", "self", ".", "which", "(", "ffname", ")", "if", "start_cmd", "is", "not", "None", ":", "break", "else", ":", "# couldn't find firefox on the system path", "raise", "RuntimeError", "(", "\"Could not find firefox in your system PATH.\"", "+", "\" Please specify the firefox binary location or install firefox\"", ")", "return", "start_cmd" ]
Return the command to start firefox.
[ "Return", "the", "command", "to", "start", "firefox", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_binary.py#L148-L170
21,175
SeleniumHQ/selenium
py/selenium/webdriver/firefox/firefox_binary.py
FirefoxBinary.which
def which(self, fname): """Returns the fully qualified path by searching Path of the given name""" for pe in os.environ['PATH'].split(os.pathsep): checkname = os.path.join(pe, fname) if os.access(checkname, os.X_OK) and not os.path.isdir(checkname): return checkname return None
python
def which(self, fname): """Returns the fully qualified path by searching Path of the given name""" for pe in os.environ['PATH'].split(os.pathsep): checkname = os.path.join(pe, fname) if os.access(checkname, os.X_OK) and not os.path.isdir(checkname): return checkname return None
[ "def", "which", "(", "self", ",", "fname", ")", ":", "for", "pe", "in", "os", ".", "environ", "[", "'PATH'", "]", ".", "split", "(", "os", ".", "pathsep", ")", ":", "checkname", "=", "os", ".", "path", ".", "join", "(", "pe", ",", "fname", ")", "if", "os", ".", "access", "(", "checkname", ",", "os", ".", "X_OK", ")", "and", "not", "os", ".", "path", ".", "isdir", "(", "checkname", ")", ":", "return", "checkname", "return", "None" ]
Returns the fully qualified path by searching Path of the given name
[ "Returns", "the", "fully", "qualified", "path", "by", "searching", "Path", "of", "the", "given", "name" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/firefox/firefox_binary.py#L210-L217
21,176
SeleniumHQ/selenium
py/selenium/webdriver/remote/remote_connection.py
RemoteConnection.get_remote_connection_headers
def get_remote_connection_headers(cls, parsed_url, keep_alive=False): """ Get headers for remote request. :Args: - parsed_url - The parsed url - keep_alive (Boolean) - Is this a keep-alive connection (default: False) """ system = platform.system().lower() if system == "darwin": system = "mac" headers = { 'Accept': 'application/json', 'Content-Type': 'application/json;charset=UTF-8', 'User-Agent': 'selenium/{} (python {})'.format(__version__, system) } if parsed_url.username: base64string = base64.b64encode('{0.username}:{0.password}'.format(parsed_url).encode()) headers.update({ 'Authorization': 'Basic {}'.format(base64string.decode()) }) if keep_alive: headers.update({ 'Connection': 'keep-alive' }) return headers
python
def get_remote_connection_headers(cls, parsed_url, keep_alive=False): """ Get headers for remote request. :Args: - parsed_url - The parsed url - keep_alive (Boolean) - Is this a keep-alive connection (default: False) """ system = platform.system().lower() if system == "darwin": system = "mac" headers = { 'Accept': 'application/json', 'Content-Type': 'application/json;charset=UTF-8', 'User-Agent': 'selenium/{} (python {})'.format(__version__, system) } if parsed_url.username: base64string = base64.b64encode('{0.username}:{0.password}'.format(parsed_url).encode()) headers.update({ 'Authorization': 'Basic {}'.format(base64string.decode()) }) if keep_alive: headers.update({ 'Connection': 'keep-alive' }) return headers
[ "def", "get_remote_connection_headers", "(", "cls", ",", "parsed_url", ",", "keep_alive", "=", "False", ")", ":", "system", "=", "platform", ".", "system", "(", ")", ".", "lower", "(", ")", "if", "system", "==", "\"darwin\"", ":", "system", "=", "\"mac\"", "headers", "=", "{", "'Accept'", ":", "'application/json'", ",", "'Content-Type'", ":", "'application/json;charset=UTF-8'", ",", "'User-Agent'", ":", "'selenium/{} (python {})'", ".", "format", "(", "__version__", ",", "system", ")", "}", "if", "parsed_url", ".", "username", ":", "base64string", "=", "base64", ".", "b64encode", "(", "'{0.username}:{0.password}'", ".", "format", "(", "parsed_url", ")", ".", "encode", "(", ")", ")", "headers", ".", "update", "(", "{", "'Authorization'", ":", "'Basic {}'", ".", "format", "(", "base64string", ".", "decode", "(", ")", ")", "}", ")", "if", "keep_alive", ":", "headers", ".", "update", "(", "{", "'Connection'", ":", "'keep-alive'", "}", ")", "return", "headers" ]
Get headers for remote request. :Args: - parsed_url - The parsed url - keep_alive (Boolean) - Is this a keep-alive connection (default: False)
[ "Get", "headers", "for", "remote", "request", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/remote_connection.py#L74-L104
21,177
SeleniumHQ/selenium
py/selenium/webdriver/remote/remote_connection.py
RemoteConnection.execute
def execute(self, command, params): """ Send a command to the remote server. Any path subtitutions required for the URL mapped to the command should be included in the command parameters. :Args: - command - A string specifying the command to execute. - params - A dictionary of named parameters to send with the command as its JSON payload. """ command_info = self._commands[command] assert command_info is not None, 'Unrecognised command %s' % command path = string.Template(command_info[1]).substitute(params) if hasattr(self, 'w3c') and self.w3c and isinstance(params, dict) and 'sessionId' in params: del params['sessionId'] data = utils.dump_json(params) url = '%s%s' % (self._url, path) return self._request(command_info[0], url, body=data)
python
def execute(self, command, params): """ Send a command to the remote server. Any path subtitutions required for the URL mapped to the command should be included in the command parameters. :Args: - command - A string specifying the command to execute. - params - A dictionary of named parameters to send with the command as its JSON payload. """ command_info = self._commands[command] assert command_info is not None, 'Unrecognised command %s' % command path = string.Template(command_info[1]).substitute(params) if hasattr(self, 'w3c') and self.w3c and isinstance(params, dict) and 'sessionId' in params: del params['sessionId'] data = utils.dump_json(params) url = '%s%s' % (self._url, path) return self._request(command_info[0], url, body=data)
[ "def", "execute", "(", "self", ",", "command", ",", "params", ")", ":", "command_info", "=", "self", ".", "_commands", "[", "command", "]", "assert", "command_info", "is", "not", "None", ",", "'Unrecognised command %s'", "%", "command", "path", "=", "string", ".", "Template", "(", "command_info", "[", "1", "]", ")", ".", "substitute", "(", "params", ")", "if", "hasattr", "(", "self", ",", "'w3c'", ")", "and", "self", ".", "w3c", "and", "isinstance", "(", "params", ",", "dict", ")", "and", "'sessionId'", "in", "params", ":", "del", "params", "[", "'sessionId'", "]", "data", "=", "utils", ".", "dump_json", "(", "params", ")", "url", "=", "'%s%s'", "%", "(", "self", ".", "_url", ",", "path", ")", "return", "self", ".", "_request", "(", "command_info", "[", "0", "]", ",", "url", ",", "body", "=", "data", ")" ]
Send a command to the remote server. Any path subtitutions required for the URL mapped to the command should be included in the command parameters. :Args: - command - A string specifying the command to execute. - params - A dictionary of named parameters to send with the command as its JSON payload.
[ "Send", "a", "command", "to", "the", "remote", "server", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/remote_connection.py#L356-L375
21,178
SeleniumHQ/selenium
py/selenium/webdriver/remote/remote_connection.py
RemoteConnection._request
def _request(self, method, url, body=None): """ Send an HTTP request to the remote server. :Args: - method - A string for the HTTP method to send the request with. - url - A string for the URL to send the request to. - body - A string for request body. Ignored unless method is POST or PUT. :Returns: A dictionary with the server's parsed JSON response. """ LOGGER.debug('%s %s %s' % (method, url, body)) parsed_url = parse.urlparse(url) headers = self.get_remote_connection_headers(parsed_url, self.keep_alive) resp = None if body and method != 'POST' and method != 'PUT': body = None if self.keep_alive: resp = self._conn.request(method, url, body=body, headers=headers) statuscode = resp.status else: http = urllib3.PoolManager(timeout=self._timeout) resp = http.request(method, url, body=body, headers=headers) statuscode = resp.status if not hasattr(resp, 'getheader'): if hasattr(resp.headers, 'getheader'): resp.getheader = lambda x: resp.headers.getheader(x) elif hasattr(resp.headers, 'get'): resp.getheader = lambda x: resp.headers.get(x) data = resp.data.decode('UTF-8') try: if 300 <= statuscode < 304: return self._request('GET', resp.getheader('location')) if 399 < statuscode <= 500: return {'status': statuscode, 'value': data} content_type = [] if resp.getheader('Content-Type') is not None: content_type = resp.getheader('Content-Type').split(';') if not any([x.startswith('image/png') for x in content_type]): try: data = utils.load_json(data.strip()) except ValueError: if 199 < statuscode < 300: status = ErrorCode.SUCCESS else: status = ErrorCode.UNKNOWN_ERROR return {'status': status, 'value': data.strip()} # Some of the drivers incorrectly return a response # with no 'value' field when they should return null. if 'value' not in data: data['value'] = None return data else: data = {'status': 0, 'value': data} return data finally: LOGGER.debug("Finished Request") resp.close()
python
def _request(self, method, url, body=None): """ Send an HTTP request to the remote server. :Args: - method - A string for the HTTP method to send the request with. - url - A string for the URL to send the request to. - body - A string for request body. Ignored unless method is POST or PUT. :Returns: A dictionary with the server's parsed JSON response. """ LOGGER.debug('%s %s %s' % (method, url, body)) parsed_url = parse.urlparse(url) headers = self.get_remote_connection_headers(parsed_url, self.keep_alive) resp = None if body and method != 'POST' and method != 'PUT': body = None if self.keep_alive: resp = self._conn.request(method, url, body=body, headers=headers) statuscode = resp.status else: http = urllib3.PoolManager(timeout=self._timeout) resp = http.request(method, url, body=body, headers=headers) statuscode = resp.status if not hasattr(resp, 'getheader'): if hasattr(resp.headers, 'getheader'): resp.getheader = lambda x: resp.headers.getheader(x) elif hasattr(resp.headers, 'get'): resp.getheader = lambda x: resp.headers.get(x) data = resp.data.decode('UTF-8') try: if 300 <= statuscode < 304: return self._request('GET', resp.getheader('location')) if 399 < statuscode <= 500: return {'status': statuscode, 'value': data} content_type = [] if resp.getheader('Content-Type') is not None: content_type = resp.getheader('Content-Type').split(';') if not any([x.startswith('image/png') for x in content_type]): try: data = utils.load_json(data.strip()) except ValueError: if 199 < statuscode < 300: status = ErrorCode.SUCCESS else: status = ErrorCode.UNKNOWN_ERROR return {'status': status, 'value': data.strip()} # Some of the drivers incorrectly return a response # with no 'value' field when they should return null. if 'value' not in data: data['value'] = None return data else: data = {'status': 0, 'value': data} return data finally: LOGGER.debug("Finished Request") resp.close()
[ "def", "_request", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'%s %s %s'", "%", "(", "method", ",", "url", ",", "body", ")", ")", "parsed_url", "=", "parse", ".", "urlparse", "(", "url", ")", "headers", "=", "self", ".", "get_remote_connection_headers", "(", "parsed_url", ",", "self", ".", "keep_alive", ")", "resp", "=", "None", "if", "body", "and", "method", "!=", "'POST'", "and", "method", "!=", "'PUT'", ":", "body", "=", "None", "if", "self", ".", "keep_alive", ":", "resp", "=", "self", ".", "_conn", ".", "request", "(", "method", ",", "url", ",", "body", "=", "body", ",", "headers", "=", "headers", ")", "statuscode", "=", "resp", ".", "status", "else", ":", "http", "=", "urllib3", ".", "PoolManager", "(", "timeout", "=", "self", ".", "_timeout", ")", "resp", "=", "http", ".", "request", "(", "method", ",", "url", ",", "body", "=", "body", ",", "headers", "=", "headers", ")", "statuscode", "=", "resp", ".", "status", "if", "not", "hasattr", "(", "resp", ",", "'getheader'", ")", ":", "if", "hasattr", "(", "resp", ".", "headers", ",", "'getheader'", ")", ":", "resp", ".", "getheader", "=", "lambda", "x", ":", "resp", ".", "headers", ".", "getheader", "(", "x", ")", "elif", "hasattr", "(", "resp", ".", "headers", ",", "'get'", ")", ":", "resp", ".", "getheader", "=", "lambda", "x", ":", "resp", ".", "headers", ".", "get", "(", "x", ")", "data", "=", "resp", ".", "data", ".", "decode", "(", "'UTF-8'", ")", "try", ":", "if", "300", "<=", "statuscode", "<", "304", ":", "return", "self", ".", "_request", "(", "'GET'", ",", "resp", ".", "getheader", "(", "'location'", ")", ")", "if", "399", "<", "statuscode", "<=", "500", ":", "return", "{", "'status'", ":", "statuscode", ",", "'value'", ":", "data", "}", "content_type", "=", "[", "]", "if", "resp", ".", "getheader", "(", "'Content-Type'", ")", "is", "not", "None", ":", "content_type", "=", "resp", ".", "getheader", "(", "'Content-Type'", ")", ".", "split", "(", "';'", ")", "if", "not", "any", "(", "[", "x", ".", "startswith", "(", "'image/png'", ")", "for", "x", "in", "content_type", "]", ")", ":", "try", ":", "data", "=", "utils", ".", "load_json", "(", "data", ".", "strip", "(", ")", ")", "except", "ValueError", ":", "if", "199", "<", "statuscode", "<", "300", ":", "status", "=", "ErrorCode", ".", "SUCCESS", "else", ":", "status", "=", "ErrorCode", ".", "UNKNOWN_ERROR", "return", "{", "'status'", ":", "status", ",", "'value'", ":", "data", ".", "strip", "(", ")", "}", "# Some of the drivers incorrectly return a response", "# with no 'value' field when they should return null.", "if", "'value'", "not", "in", "data", ":", "data", "[", "'value'", "]", "=", "None", "return", "data", "else", ":", "data", "=", "{", "'status'", ":", "0", ",", "'value'", ":", "data", "}", "return", "data", "finally", ":", "LOGGER", ".", "debug", "(", "\"Finished Request\"", ")", "resp", ".", "close", "(", ")" ]
Send an HTTP request to the remote server. :Args: - method - A string for the HTTP method to send the request with. - url - A string for the URL to send the request to. - body - A string for request body. Ignored unless method is POST or PUT. :Returns: A dictionary with the server's parsed JSON response.
[ "Send", "an", "HTTP", "request", "to", "the", "remote", "server", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/remote_connection.py#L377-L442
21,179
SeleniumHQ/selenium
py/selenium/webdriver/support/select.py
Select.all_selected_options
def all_selected_options(self): """Returns a list of all selected options belonging to this select tag""" ret = [] for opt in self.options: if opt.is_selected(): ret.append(opt) return ret
python
def all_selected_options(self): """Returns a list of all selected options belonging to this select tag""" ret = [] for opt in self.options: if opt.is_selected(): ret.append(opt) return ret
[ "def", "all_selected_options", "(", "self", ")", ":", "ret", "=", "[", "]", "for", "opt", "in", "self", ".", "options", ":", "if", "opt", ".", "is_selected", "(", ")", ":", "ret", ".", "append", "(", "opt", ")", "return", "ret" ]
Returns a list of all selected options belonging to this select tag
[ "Returns", "a", "list", "of", "all", "selected", "options", "belonging", "to", "this", "select", "tag" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/select.py#L50-L56
21,180
SeleniumHQ/selenium
py/selenium/webdriver/support/select.py
Select.select_by_index
def select_by_index(self, index): """Select the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting. :Args: - index - The option at this index will be selected throws NoSuchElementException If there is no option with specified index in SELECT """ match = str(index) for opt in self.options: if opt.get_attribute("index") == match: self._setSelected(opt) return raise NoSuchElementException("Could not locate element with index %d" % index)
python
def select_by_index(self, index): """Select the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting. :Args: - index - The option at this index will be selected throws NoSuchElementException If there is no option with specified index in SELECT """ match = str(index) for opt in self.options: if opt.get_attribute("index") == match: self._setSelected(opt) return raise NoSuchElementException("Could not locate element with index %d" % index)
[ "def", "select_by_index", "(", "self", ",", "index", ")", ":", "match", "=", "str", "(", "index", ")", "for", "opt", "in", "self", ".", "options", ":", "if", "opt", ".", "get_attribute", "(", "\"index\"", ")", "==", "match", ":", "self", ".", "_setSelected", "(", "opt", ")", "return", "raise", "NoSuchElementException", "(", "\"Could not locate element with index %d\"", "%", "index", ")" ]
Select the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting. :Args: - index - The option at this index will be selected throws NoSuchElementException If there is no option with specified index in SELECT
[ "Select", "the", "option", "at", "the", "given", "index", ".", "This", "is", "done", "by", "examing", "the", "index", "attribute", "of", "an", "element", "and", "not", "merely", "by", "counting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/select.py#L89-L103
21,181
SeleniumHQ/selenium
py/selenium/webdriver/support/select.py
Select.deselect_all
def deselect_all(self): """Clear all selected entries. This is only valid when the SELECT supports multiple selections. throws NotImplementedError If the SELECT does not support multiple selections """ if not self.is_multiple: raise NotImplementedError("You may only deselect all options of a multi-select") for opt in self.options: self._unsetSelected(opt)
python
def deselect_all(self): """Clear all selected entries. This is only valid when the SELECT supports multiple selections. throws NotImplementedError If the SELECT does not support multiple selections """ if not self.is_multiple: raise NotImplementedError("You may only deselect all options of a multi-select") for opt in self.options: self._unsetSelected(opt)
[ "def", "deselect_all", "(", "self", ")", ":", "if", "not", "self", ".", "is_multiple", ":", "raise", "NotImplementedError", "(", "\"You may only deselect all options of a multi-select\"", ")", "for", "opt", "in", "self", ".", "options", ":", "self", ".", "_unsetSelected", "(", "opt", ")" ]
Clear all selected entries. This is only valid when the SELECT supports multiple selections. throws NotImplementedError If the SELECT does not support multiple selections
[ "Clear", "all", "selected", "entries", ".", "This", "is", "only", "valid", "when", "the", "SELECT", "supports", "multiple", "selections", ".", "throws", "NotImplementedError", "If", "the", "SELECT", "does", "not", "support", "multiple", "selections" ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/select.py#L142-L149
21,182
SeleniumHQ/selenium
py/selenium/webdriver/support/select.py
Select.deselect_by_index
def deselect_by_index(self, index): """Deselect the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting. :Args: - index - The option at this index will be deselected throws NoSuchElementException If there is no option with specified index in SELECT """ if not self.is_multiple: raise NotImplementedError("You may only deselect options of a multi-select") for opt in self.options: if opt.get_attribute("index") == str(index): self._unsetSelected(opt) return raise NoSuchElementException("Could not locate element with index %d" % index)
python
def deselect_by_index(self, index): """Deselect the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting. :Args: - index - The option at this index will be deselected throws NoSuchElementException If there is no option with specified index in SELECT """ if not self.is_multiple: raise NotImplementedError("You may only deselect options of a multi-select") for opt in self.options: if opt.get_attribute("index") == str(index): self._unsetSelected(opt) return raise NoSuchElementException("Could not locate element with index %d" % index)
[ "def", "deselect_by_index", "(", "self", ",", "index", ")", ":", "if", "not", "self", ".", "is_multiple", ":", "raise", "NotImplementedError", "(", "\"You may only deselect options of a multi-select\"", ")", "for", "opt", "in", "self", ".", "options", ":", "if", "opt", ".", "get_attribute", "(", "\"index\"", ")", "==", "str", "(", "index", ")", ":", "self", ".", "_unsetSelected", "(", "opt", ")", "return", "raise", "NoSuchElementException", "(", "\"Could not locate element with index %d\"", "%", "index", ")" ]
Deselect the option at the given index. This is done by examing the "index" attribute of an element, and not merely by counting. :Args: - index - The option at this index will be deselected throws NoSuchElementException If there is no option with specified index in SELECT
[ "Deselect", "the", "option", "at", "the", "given", "index", ".", "This", "is", "done", "by", "examing", "the", "index", "attribute", "of", "an", "element", "and", "not", "merely", "by", "counting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/support/select.py#L173-L188
21,183
SeleniumHQ/selenium
third_party/py/googlestorage/publish_release.py
_upload
def _upload(auth_http, project_id, bucket_name, file_path, object_name, acl): """Uploads a file to Google Cloud Storage. Args: auth_http: An authorized httplib2.Http instance. project_id: The project to upload to. bucket_name: The bucket to upload to. file_path: Path to the file to upload. object_name: The name within the bucket to upload to. acl: The ACL to assign to the uploaded file. """ with open(file_path, 'rb') as f: data = f.read() content_type, content_encoding = mimetypes.guess_type(file_path) headers = { 'x-goog-project-id': project_id, 'x-goog-api-version': API_VERSION, 'x-goog-acl': acl, 'Content-Length': '%d' % len(data) } if content_type: headers['Content-Type'] = content_type if content_type: headers['Content-Encoding'] = content_encoding try: response, content = auth_http.request( 'http://%s.storage.googleapis.com/%s' % (bucket_name, object_name), method='PUT', headers=headers, body=data) except httplib2.ServerNotFoundError, se: raise Error(404, 'Server not found.') if response.status >= 300: raise Error(response.status, response.reason) return content
python
def _upload(auth_http, project_id, bucket_name, file_path, object_name, acl): """Uploads a file to Google Cloud Storage. Args: auth_http: An authorized httplib2.Http instance. project_id: The project to upload to. bucket_name: The bucket to upload to. file_path: Path to the file to upload. object_name: The name within the bucket to upload to. acl: The ACL to assign to the uploaded file. """ with open(file_path, 'rb') as f: data = f.read() content_type, content_encoding = mimetypes.guess_type(file_path) headers = { 'x-goog-project-id': project_id, 'x-goog-api-version': API_VERSION, 'x-goog-acl': acl, 'Content-Length': '%d' % len(data) } if content_type: headers['Content-Type'] = content_type if content_type: headers['Content-Encoding'] = content_encoding try: response, content = auth_http.request( 'http://%s.storage.googleapis.com/%s' % (bucket_name, object_name), method='PUT', headers=headers, body=data) except httplib2.ServerNotFoundError, se: raise Error(404, 'Server not found.') if response.status >= 300: raise Error(response.status, response.reason) return content
[ "def", "_upload", "(", "auth_http", ",", "project_id", ",", "bucket_name", ",", "file_path", ",", "object_name", ",", "acl", ")", ":", "with", "open", "(", "file_path", ",", "'rb'", ")", "as", "f", ":", "data", "=", "f", ".", "read", "(", ")", "content_type", ",", "content_encoding", "=", "mimetypes", ".", "guess_type", "(", "file_path", ")", "headers", "=", "{", "'x-goog-project-id'", ":", "project_id", ",", "'x-goog-api-version'", ":", "API_VERSION", ",", "'x-goog-acl'", ":", "acl", ",", "'Content-Length'", ":", "'%d'", "%", "len", "(", "data", ")", "}", "if", "content_type", ":", "headers", "[", "'Content-Type'", "]", "=", "content_type", "if", "content_type", ":", "headers", "[", "'Content-Encoding'", "]", "=", "content_encoding", "try", ":", "response", ",", "content", "=", "auth_http", ".", "request", "(", "'http://%s.storage.googleapis.com/%s'", "%", "(", "bucket_name", ",", "object_name", ")", ",", "method", "=", "'PUT'", ",", "headers", "=", "headers", ",", "body", "=", "data", ")", "except", "httplib2", ".", "ServerNotFoundError", ",", "se", ":", "raise", "Error", "(", "404", ",", "'Server not found.'", ")", "if", "response", ".", "status", ">=", "300", ":", "raise", "Error", "(", "response", ".", "status", ",", "response", ".", "reason", ")", "return", "content" ]
Uploads a file to Google Cloud Storage. Args: auth_http: An authorized httplib2.Http instance. project_id: The project to upload to. bucket_name: The bucket to upload to. file_path: Path to the file to upload. object_name: The name within the bucket to upload to. acl: The ACL to assign to the uploaded file.
[ "Uploads", "a", "file", "to", "Google", "Cloud", "Storage", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/third_party/py/googlestorage/publish_release.py#L102-L138
21,184
SeleniumHQ/selenium
third_party/py/googlestorage/publish_release.py
_authenticate
def _authenticate(secrets_file): """Runs the OAuth 2.0 installed application flow. Returns: An authorized httplib2.Http instance. """ flow = oauthclient.flow_from_clientsecrets( secrets_file, scope=OAUTH_SCOPE, message=('Failed to initialized OAuth 2.0 flow with secrets ' 'file: %s' % secrets_file)) storage = oauthfile.Storage(OAUTH_CREDENTIALS_FILE) credentials = storage.get() if credentials is None or credentials.invalid: credentials = oauthtools.run_flow(flow, storage, oauthtools.argparser.parse_args(args=[])) http = httplib2.Http() return credentials.authorize(http)
python
def _authenticate(secrets_file): """Runs the OAuth 2.0 installed application flow. Returns: An authorized httplib2.Http instance. """ flow = oauthclient.flow_from_clientsecrets( secrets_file, scope=OAUTH_SCOPE, message=('Failed to initialized OAuth 2.0 flow with secrets ' 'file: %s' % secrets_file)) storage = oauthfile.Storage(OAUTH_CREDENTIALS_FILE) credentials = storage.get() if credentials is None or credentials.invalid: credentials = oauthtools.run_flow(flow, storage, oauthtools.argparser.parse_args(args=[])) http = httplib2.Http() return credentials.authorize(http)
[ "def", "_authenticate", "(", "secrets_file", ")", ":", "flow", "=", "oauthclient", ".", "flow_from_clientsecrets", "(", "secrets_file", ",", "scope", "=", "OAUTH_SCOPE", ",", "message", "=", "(", "'Failed to initialized OAuth 2.0 flow with secrets '", "'file: %s'", "%", "secrets_file", ")", ")", "storage", "=", "oauthfile", ".", "Storage", "(", "OAUTH_CREDENTIALS_FILE", ")", "credentials", "=", "storage", ".", "get", "(", ")", "if", "credentials", "is", "None", "or", "credentials", ".", "invalid", ":", "credentials", "=", "oauthtools", ".", "run_flow", "(", "flow", ",", "storage", ",", "oauthtools", ".", "argparser", ".", "parse_args", "(", "args", "=", "[", "]", ")", ")", "http", "=", "httplib2", ".", "Http", "(", ")", "return", "credentials", ".", "authorize", "(", "http", ")" ]
Runs the OAuth 2.0 installed application flow. Returns: An authorized httplib2.Http instance.
[ "Runs", "the", "OAuth", "2", ".", "0", "installed", "application", "flow", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/third_party/py/googlestorage/publish_release.py#L141-L157
21,185
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.auto_detect
def auto_detect(self, value): """ Sets autodetect setting. :Args: - value: The autodetect value. """ if isinstance(value, bool): if self.autodetect is not value: self._verify_proxy_type_compatibility(ProxyType.AUTODETECT) self.proxyType = ProxyType.AUTODETECT self.autodetect = value else: raise ValueError("Autodetect proxy value needs to be a boolean")
python
def auto_detect(self, value): """ Sets autodetect setting. :Args: - value: The autodetect value. """ if isinstance(value, bool): if self.autodetect is not value: self._verify_proxy_type_compatibility(ProxyType.AUTODETECT) self.proxyType = ProxyType.AUTODETECT self.autodetect = value else: raise ValueError("Autodetect proxy value needs to be a boolean")
[ "def", "auto_detect", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "if", "self", ".", "autodetect", "is", "not", "value", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "AUTODETECT", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "AUTODETECT", "self", ".", "autodetect", "=", "value", "else", ":", "raise", "ValueError", "(", "\"Autodetect proxy value needs to be a boolean\"", ")" ]
Sets autodetect setting. :Args: - value: The autodetect value.
[ "Sets", "autodetect", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L136-L149
21,186
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.ftp_proxy
def ftp_proxy(self, value): """ Sets ftp proxy setting. :Args: - value: The ftp proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.ftpProxy = value
python
def ftp_proxy(self, value): """ Sets ftp proxy setting. :Args: - value: The ftp proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.ftpProxy = value
[ "def", "ftp_proxy", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "ftpProxy", "=", "value" ]
Sets ftp proxy setting. :Args: - value: The ftp proxy value.
[ "Sets", "ftp", "proxy", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L159-L168
21,187
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.http_proxy
def http_proxy(self, value): """ Sets http proxy setting. :Args: - value: The http proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.httpProxy = value
python
def http_proxy(self, value): """ Sets http proxy setting. :Args: - value: The http proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.httpProxy = value
[ "def", "http_proxy", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "httpProxy", "=", "value" ]
Sets http proxy setting. :Args: - value: The http proxy value.
[ "Sets", "http", "proxy", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L178-L187
21,188
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.no_proxy
def no_proxy(self, value): """ Sets noproxy setting. :Args: - value: The noproxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.noProxy = value
python
def no_proxy(self, value): """ Sets noproxy setting. :Args: - value: The noproxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.noProxy = value
[ "def", "no_proxy", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "noProxy", "=", "value" ]
Sets noproxy setting. :Args: - value: The noproxy value.
[ "Sets", "noproxy", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L197-L206
21,189
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.proxy_autoconfig_url
def proxy_autoconfig_url(self, value): """ Sets proxy autoconfig url setting. :Args: - value: The proxy autoconfig url value. """ self._verify_proxy_type_compatibility(ProxyType.PAC) self.proxyType = ProxyType.PAC self.proxyAutoconfigUrl = value
python
def proxy_autoconfig_url(self, value): """ Sets proxy autoconfig url setting. :Args: - value: The proxy autoconfig url value. """ self._verify_proxy_type_compatibility(ProxyType.PAC) self.proxyType = ProxyType.PAC self.proxyAutoconfigUrl = value
[ "def", "proxy_autoconfig_url", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "PAC", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "PAC", "self", ".", "proxyAutoconfigUrl", "=", "value" ]
Sets proxy autoconfig url setting. :Args: - value: The proxy autoconfig url value.
[ "Sets", "proxy", "autoconfig", "url", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L216-L225
21,190
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.ssl_proxy
def ssl_proxy(self, value): """ Sets https proxy setting. :Args: - value: The https proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.sslProxy = value
python
def ssl_proxy(self, value): """ Sets https proxy setting. :Args: - value: The https proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.sslProxy = value
[ "def", "ssl_proxy", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "sslProxy", "=", "value" ]
Sets https proxy setting. :Args: - value: The https proxy value.
[ "Sets", "https", "proxy", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L235-L244
21,191
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.socks_proxy
def socks_proxy(self, value): """ Sets socks proxy setting. :Args: - value: The socks proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksProxy = value
python
def socks_proxy(self, value): """ Sets socks proxy setting. :Args: - value: The socks proxy value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksProxy = value
[ "def", "socks_proxy", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "socksProxy", "=", "value" ]
Sets socks proxy setting. :Args: - value: The socks proxy value.
[ "Sets", "socks", "proxy", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L254-L263
21,192
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.socks_username
def socks_username(self, value): """ Sets socks proxy username setting. :Args: - value: The socks proxy username value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksUsername = value
python
def socks_username(self, value): """ Sets socks proxy username setting. :Args: - value: The socks proxy username value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksUsername = value
[ "def", "socks_username", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "socksUsername", "=", "value" ]
Sets socks proxy username setting. :Args: - value: The socks proxy username value.
[ "Sets", "socks", "proxy", "username", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L273-L282
21,193
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.socks_password
def socks_password(self, value): """ Sets socks proxy password setting. :Args: - value: The socks proxy password value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksPassword = value
python
def socks_password(self, value): """ Sets socks proxy password setting. :Args: - value: The socks proxy password value. """ self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksPassword = value
[ "def", "socks_password", "(", "self", ",", "value", ")", ":", "self", ".", "_verify_proxy_type_compatibility", "(", "ProxyType", ".", "MANUAL", ")", "self", ".", "proxyType", "=", "ProxyType", ".", "MANUAL", "self", ".", "socksPassword", "=", "value" ]
Sets socks proxy password setting. :Args: - value: The socks proxy password value.
[ "Sets", "socks", "proxy", "password", "setting", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L292-L301
21,194
SeleniumHQ/selenium
py/selenium/webdriver/common/proxy.py
Proxy.add_to_capabilities
def add_to_capabilities(self, capabilities): """ Adds proxy information as capability in specified capabilities. :Args: - capabilities: The capabilities to which proxy will be added. """ proxy_caps = {} proxy_caps['proxyType'] = self.proxyType['string'] if self.autodetect: proxy_caps['autodetect'] = self.autodetect if self.ftpProxy: proxy_caps['ftpProxy'] = self.ftpProxy if self.httpProxy: proxy_caps['httpProxy'] = self.httpProxy if self.proxyAutoconfigUrl: proxy_caps['proxyAutoconfigUrl'] = self.proxyAutoconfigUrl if self.sslProxy: proxy_caps['sslProxy'] = self.sslProxy if self.noProxy: proxy_caps['noProxy'] = self.noProxy if self.socksProxy: proxy_caps['socksProxy'] = self.socksProxy if self.socksUsername: proxy_caps['socksUsername'] = self.socksUsername if self.socksPassword: proxy_caps['socksPassword'] = self.socksPassword capabilities['proxy'] = proxy_caps
python
def add_to_capabilities(self, capabilities): """ Adds proxy information as capability in specified capabilities. :Args: - capabilities: The capabilities to which proxy will be added. """ proxy_caps = {} proxy_caps['proxyType'] = self.proxyType['string'] if self.autodetect: proxy_caps['autodetect'] = self.autodetect if self.ftpProxy: proxy_caps['ftpProxy'] = self.ftpProxy if self.httpProxy: proxy_caps['httpProxy'] = self.httpProxy if self.proxyAutoconfigUrl: proxy_caps['proxyAutoconfigUrl'] = self.proxyAutoconfigUrl if self.sslProxy: proxy_caps['sslProxy'] = self.sslProxy if self.noProxy: proxy_caps['noProxy'] = self.noProxy if self.socksProxy: proxy_caps['socksProxy'] = self.socksProxy if self.socksUsername: proxy_caps['socksUsername'] = self.socksUsername if self.socksPassword: proxy_caps['socksPassword'] = self.socksPassword capabilities['proxy'] = proxy_caps
[ "def", "add_to_capabilities", "(", "self", ",", "capabilities", ")", ":", "proxy_caps", "=", "{", "}", "proxy_caps", "[", "'proxyType'", "]", "=", "self", ".", "proxyType", "[", "'string'", "]", "if", "self", ".", "autodetect", ":", "proxy_caps", "[", "'autodetect'", "]", "=", "self", ".", "autodetect", "if", "self", ".", "ftpProxy", ":", "proxy_caps", "[", "'ftpProxy'", "]", "=", "self", ".", "ftpProxy", "if", "self", ".", "httpProxy", ":", "proxy_caps", "[", "'httpProxy'", "]", "=", "self", ".", "httpProxy", "if", "self", ".", "proxyAutoconfigUrl", ":", "proxy_caps", "[", "'proxyAutoconfigUrl'", "]", "=", "self", ".", "proxyAutoconfigUrl", "if", "self", ".", "sslProxy", ":", "proxy_caps", "[", "'sslProxy'", "]", "=", "self", ".", "sslProxy", "if", "self", ".", "noProxy", ":", "proxy_caps", "[", "'noProxy'", "]", "=", "self", ".", "noProxy", "if", "self", ".", "socksProxy", ":", "proxy_caps", "[", "'socksProxy'", "]", "=", "self", ".", "socksProxy", "if", "self", ".", "socksUsername", ":", "proxy_caps", "[", "'socksUsername'", "]", "=", "self", ".", "socksUsername", "if", "self", ".", "socksPassword", ":", "proxy_caps", "[", "'socksPassword'", "]", "=", "self", ".", "socksPassword", "capabilities", "[", "'proxy'", "]", "=", "proxy_caps" ]
Adds proxy information as capability in specified capabilities. :Args: - capabilities: The capabilities to which proxy will be added.
[ "Adds", "proxy", "information", "as", "capability", "in", "specified", "capabilities", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L307-L334
21,195
SeleniumHQ/selenium
py/selenium/webdriver/common/utils.py
find_connectable_ip
def find_connectable_ip(host, port=None): """Resolve a hostname to an IP, preferring IPv4 addresses. We prefer IPv4 so that we don't change behavior from previous IPv4-only implementations, and because some drivers (e.g., FirefoxDriver) do not support IPv6 connections. If the optional port number is provided, only IPs that listen on the given port are considered. :Args: - host - A hostname. - port - Optional port number. :Returns: A single IP address, as a string. If any IPv4 address is found, one is returned. Otherwise, if any IPv6 address is found, one is returned. If neither, then None is returned. """ try: addrinfos = socket.getaddrinfo(host, None) except socket.gaierror: return None ip = None for family, _, _, _, sockaddr in addrinfos: connectable = True if port: connectable = is_connectable(port, sockaddr[0]) if connectable and family == socket.AF_INET: return sockaddr[0] if connectable and not ip and family == socket.AF_INET6: ip = sockaddr[0] return ip
python
def find_connectable_ip(host, port=None): """Resolve a hostname to an IP, preferring IPv4 addresses. We prefer IPv4 so that we don't change behavior from previous IPv4-only implementations, and because some drivers (e.g., FirefoxDriver) do not support IPv6 connections. If the optional port number is provided, only IPs that listen on the given port are considered. :Args: - host - A hostname. - port - Optional port number. :Returns: A single IP address, as a string. If any IPv4 address is found, one is returned. Otherwise, if any IPv6 address is found, one is returned. If neither, then None is returned. """ try: addrinfos = socket.getaddrinfo(host, None) except socket.gaierror: return None ip = None for family, _, _, _, sockaddr in addrinfos: connectable = True if port: connectable = is_connectable(port, sockaddr[0]) if connectable and family == socket.AF_INET: return sockaddr[0] if connectable and not ip and family == socket.AF_INET6: ip = sockaddr[0] return ip
[ "def", "find_connectable_ip", "(", "host", ",", "port", "=", "None", ")", ":", "try", ":", "addrinfos", "=", "socket", ".", "getaddrinfo", "(", "host", ",", "None", ")", "except", "socket", ".", "gaierror", ":", "return", "None", "ip", "=", "None", "for", "family", ",", "_", ",", "_", ",", "_", ",", "sockaddr", "in", "addrinfos", ":", "connectable", "=", "True", "if", "port", ":", "connectable", "=", "is_connectable", "(", "port", ",", "sockaddr", "[", "0", "]", ")", "if", "connectable", "and", "family", "==", "socket", ".", "AF_INET", ":", "return", "sockaddr", "[", "0", "]", "if", "connectable", "and", "not", "ip", "and", "family", "==", "socket", ".", "AF_INET6", ":", "ip", "=", "sockaddr", "[", "0", "]", "return", "ip" ]
Resolve a hostname to an IP, preferring IPv4 addresses. We prefer IPv4 so that we don't change behavior from previous IPv4-only implementations, and because some drivers (e.g., FirefoxDriver) do not support IPv6 connections. If the optional port number is provided, only IPs that listen on the given port are considered. :Args: - host - A hostname. - port - Optional port number. :Returns: A single IP address, as a string. If any IPv4 address is found, one is returned. Otherwise, if any IPv6 address is found, one is returned. If neither, then None is returned.
[ "Resolve", "a", "hostname", "to", "an", "IP", "preferring", "IPv4", "addresses", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/utils.py#L46-L81
21,196
SeleniumHQ/selenium
py/selenium/webdriver/common/utils.py
join_host_port
def join_host_port(host, port): """Joins a hostname and port together. This is a minimal implementation intended to cope with IPv6 literals. For example, _join_host_port('::1', 80) == '[::1]:80'. :Args: - host - A hostname. - port - An integer port. """ if ':' in host and not host.startswith('['): return '[%s]:%d' % (host, port) return '%s:%d' % (host, port)
python
def join_host_port(host, port): """Joins a hostname and port together. This is a minimal implementation intended to cope with IPv6 literals. For example, _join_host_port('::1', 80) == '[::1]:80'. :Args: - host - A hostname. - port - An integer port. """ if ':' in host and not host.startswith('['): return '[%s]:%d' % (host, port) return '%s:%d' % (host, port)
[ "def", "join_host_port", "(", "host", ",", "port", ")", ":", "if", "':'", "in", "host", "and", "not", "host", ".", "startswith", "(", "'['", ")", ":", "return", "'[%s]:%d'", "%", "(", "host", ",", "port", ")", "return", "'%s:%d'", "%", "(", "host", ",", "port", ")" ]
Joins a hostname and port together. This is a minimal implementation intended to cope with IPv6 literals. For example, _join_host_port('::1', 80) == '[::1]:80'. :Args: - host - A hostname. - port - An integer port.
[ "Joins", "a", "hostname", "and", "port", "together", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/utils.py#L84-L97
21,197
SeleniumHQ/selenium
py/selenium/webdriver/common/utils.py
is_connectable
def is_connectable(port, host="localhost"): """ Tries to connect to the server at port to see if it is running. :Args: - port - The port to connect. """ socket_ = None try: socket_ = socket.create_connection((host, port), 1) result = True except _is_connectable_exceptions: result = False finally: if socket_: socket_.close() return result
python
def is_connectable(port, host="localhost"): """ Tries to connect to the server at port to see if it is running. :Args: - port - The port to connect. """ socket_ = None try: socket_ = socket.create_connection((host, port), 1) result = True except _is_connectable_exceptions: result = False finally: if socket_: socket_.close() return result
[ "def", "is_connectable", "(", "port", ",", "host", "=", "\"localhost\"", ")", ":", "socket_", "=", "None", "try", ":", "socket_", "=", "socket", ".", "create_connection", "(", "(", "host", ",", "port", ")", ",", "1", ")", "result", "=", "True", "except", "_is_connectable_exceptions", ":", "result", "=", "False", "finally", ":", "if", "socket_", ":", "socket_", ".", "close", "(", ")", "return", "result" ]
Tries to connect to the server at port to see if it is running. :Args: - port - The port to connect.
[ "Tries", "to", "connect", "to", "the", "server", "at", "port", "to", "see", "if", "it", "is", "running", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/utils.py#L100-L116
21,198
SeleniumHQ/selenium
py/selenium/webdriver/common/utils.py
keys_to_typing
def keys_to_typing(value): """Processes the values that will be typed in the element.""" typing = [] for val in value: if isinstance(val, Keys): typing.append(val) elif isinstance(val, int): val = str(val) for i in range(len(val)): typing.append(val[i]) else: for i in range(len(val)): typing.append(val[i]) return typing
python
def keys_to_typing(value): """Processes the values that will be typed in the element.""" typing = [] for val in value: if isinstance(val, Keys): typing.append(val) elif isinstance(val, int): val = str(val) for i in range(len(val)): typing.append(val[i]) else: for i in range(len(val)): typing.append(val[i]) return typing
[ "def", "keys_to_typing", "(", "value", ")", ":", "typing", "=", "[", "]", "for", "val", "in", "value", ":", "if", "isinstance", "(", "val", ",", "Keys", ")", ":", "typing", ".", "append", "(", "val", ")", "elif", "isinstance", "(", "val", ",", "int", ")", ":", "val", "=", "str", "(", "val", ")", "for", "i", "in", "range", "(", "len", "(", "val", ")", ")", ":", "typing", ".", "append", "(", "val", "[", "i", "]", ")", "else", ":", "for", "i", "in", "range", "(", "len", "(", "val", ")", ")", ":", "typing", ".", "append", "(", "val", "[", "i", "]", ")", "return", "typing" ]
Processes the values that will be typed in the element.
[ "Processes", "the", "values", "that", "will", "be", "typed", "in", "the", "element", "." ]
df40c28b41d4b3953f90eaff84838a9ac052b84a
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/utils.py#L142-L155
21,199
explosion/spaCy
examples/pipeline/custom_attr_methods.py
to_html
def to_html(doc, output="/tmp", style="dep"): """Doc method extension for saving the current state as a displaCy visualization. """ # generate filename from first six non-punct tokens file_name = "-".join([w.text for w in doc[:6] if not w.is_punct]) + ".html" html = displacy.render(doc, style=style, page=True) # render markup if output is not None: output_path = Path(output) if not output_path.exists(): output_path.mkdir() output_file = Path(output) / file_name output_file.open("w", encoding="utf-8").write(html) # save to file print("Saved HTML to {}".format(output_file)) else: print(html)
python
def to_html(doc, output="/tmp", style="dep"): """Doc method extension for saving the current state as a displaCy visualization. """ # generate filename from first six non-punct tokens file_name = "-".join([w.text for w in doc[:6] if not w.is_punct]) + ".html" html = displacy.render(doc, style=style, page=True) # render markup if output is not None: output_path = Path(output) if not output_path.exists(): output_path.mkdir() output_file = Path(output) / file_name output_file.open("w", encoding="utf-8").write(html) # save to file print("Saved HTML to {}".format(output_file)) else: print(html)
[ "def", "to_html", "(", "doc", ",", "output", "=", "\"/tmp\"", ",", "style", "=", "\"dep\"", ")", ":", "# generate filename from first six non-punct tokens", "file_name", "=", "\"-\"", ".", "join", "(", "[", "w", ".", "text", "for", "w", "in", "doc", "[", ":", "6", "]", "if", "not", "w", ".", "is_punct", "]", ")", "+", "\".html\"", "html", "=", "displacy", ".", "render", "(", "doc", ",", "style", "=", "style", ",", "page", "=", "True", ")", "# render markup", "if", "output", "is", "not", "None", ":", "output_path", "=", "Path", "(", "output", ")", "if", "not", "output_path", ".", "exists", "(", ")", ":", "output_path", ".", "mkdir", "(", ")", "output_file", "=", "Path", "(", "output", ")", "/", "file_name", "output_file", ".", "open", "(", "\"w\"", ",", "encoding", "=", "\"utf-8\"", ")", ".", "write", "(", "html", ")", "# save to file", "print", "(", "\"Saved HTML to {}\"", ".", "format", "(", "output_file", ")", ")", "else", ":", "print", "(", "html", ")" ]
Doc method extension for saving the current state as a displaCy visualization.
[ "Doc", "method", "extension", "for", "saving", "the", "current", "state", "as", "a", "displaCy", "visualization", "." ]
8ee4100f8ffb336886208a1ea827bf4c745e2709
https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/examples/pipeline/custom_attr_methods.py#L43-L58