Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def flow(self)->FlowField: "Access the flow-field grid after applying queued affine and coord transforms." if self._affine_mat is not None: self._flow = _affine_inv_mult(self._flow, self._affine_mat) self._affine_mat = None ...
[]
Please provide a description of the function:def coord(self, func:CoordFunc, *args, **kwargs)->'ImagePoints': "Put `func` with `args` and `kwargs` in `self.flow_func` for later." if 'invert' in kwargs: kwargs['invert'] = True else: warn(f"{func.__name__} isn't implemented for {self.__class__}.")...
[]
Please provide a description of the function:def pixel(self, func:PixelFunc, *args, **kwargs)->'ImagePoints': "Equivalent to `self = func_flow(self)`." self = func(self, *args, **kwargs) self.transformed=True return self
[]
Please provide a description of the function:def resize(self, size:Union[int,TensorImageSize]) -> 'ImagePoints': "Resize the image to `size`, size can be a single int." if isinstance(size, int): size=(1, size, size) self._flow.size = size[1:] return self
[]
Please provide a description of the function:def data(self)->Tensor: "Return the points associated to this object." flow = self.flow #This updates flow before we test if some transforms happened if self.transformed: if 'remove_out' not in self.sample_kwargs or self.sample_kwargs['rem...
[]
Please provide a description of the function:def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[str]=None, hide_axis:bool=True, **kwargs): "Show the `ImagePoints` on `ax`." if ax is None: _,ax = plt.subplots(figsize=figsize) pnt = scale_flow(FlowField(self.size, self.data), to_...
[]
Please provide a description of the function:def clone(self) -> 'ImageBBox': "Mimic the behavior of torch.clone for `Image` objects." flow = FlowField(self.size, self.flow.flow.clone()) return self.__class__(flow, scale=False, y_first=False, labels=self.labels, pad_idx=self.pad_idx)
[]
Please provide a description of the function:def create(cls, h:int, w:int, bboxes:Collection[Collection[int]], labels:Collection=None, classes:dict=None, pad_idx:int=0, scale:bool=True)->'ImageBBox': "Create an ImageBBox object from `bboxes`." if isinstance(bboxes, np.ndarray) and bboxes....
[]
Please provide a description of the function:def show(self, y:Image=None, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[str]=None, hide_axis:bool=True, color:str='white', **kwargs): "Show the `ImageBBox` on `ax`." if ax is None: _,ax = plt.subplots(figsize=figsize) bboxes, lbls =...
[]
Please provide a description of the function:def calc(self, x:Image, *args:Any, **kwargs:Any)->Image: "Apply to image `x`, wrapping it if necessary." if self._wrap: return getattr(x, self._wrap)(self.func, *args, **kwargs) else: return self.func(x, *args, **kwargs)
[]
Please provide a description of the function:def url2path(url, data=True, ext:str='.tgz'): "Change `url` to a path." name = url2name(url) return datapath4file(name, ext=ext, archive=False) if data else modelpath4file(name, ext=ext)
[]
Please provide a description of the function:def modelpath4file(filename, ext:str='.tgz'): "Return model path to `filename`, checking locally first then in the config file." local_path = URLs.LOCAL_PATH/'models'/filename if local_path.exists() or local_path.with_suffix(ext).exists(): return local_path e...
[]
Please provide a description of the function:def datapath4file(filename, ext:str='.tgz', archive=True): "Return data path to `filename`, checking locally first then in the config file." local_path = URLs.LOCAL_PATH/'data'/filename if local_path.exists() or local_path.with_suffix(ext).exists(): return local_...
[]
Please provide a description of the function:def download_data(url:str, fname:PathOrStr=None, data:bool=True, ext:str='.tgz') -> Path: "Download `url` to destination `fname`." fname = Path(ifnone(fname, _url2tgz(url, data, ext=ext))) os.makedirs(fname.parent, exist_ok=True) if not fname.exists(): ...
[]
Please provide a description of the function:def untar_data(url:str, fname:PathOrStr=None, dest:PathOrStr=None, data=True, force_download=False) -> Path: "Download `url` to `fname` if `dest` doesn't exist, and un-tgz to folder `dest`." dest = url2path(url, data) if dest is None else Path(dest)/url2name(url) ...
[]
Please provide a description of the function:def get_key(cls, key): "Get the path to `key` in the config file." return cls.get().get(key, cls.DEFAULT_CONFIG.get(key,None))
[]
Please provide a description of the function:def get(cls, fpath=None, create_missing=True): "Retrieve the `Config` in `fpath`." fpath = _expand_path(fpath or cls.DEFAULT_CONFIG_PATH) if not fpath.exists() and create_missing: cls.create(fpath) assert fpath.exists(), f'Could not find confi...
[]
Please provide a description of the function:def create(cls, fpath): "Creates a `Config` from `fpath`." fpath = _expand_path(fpath) assert(fpath.suffix == '.yml') if fpath.exists(): return fpath.parent.mkdir(parents=True, exist_ok=True) with open(fpath, 'w') as yaml_file:...
[]
Please provide a description of the function:def on_batch_begin(self, last_input, last_target, train, **kwargs): "Applies mixup to `last_input` and `last_target` if `train`." if not train: return lambd = np.random.beta(self.alpha, self.alpha, last_target.size(0)) lambd = np.concatenate([...
[]
Please provide a description of the function:def make_date(df:DataFrame, date_field:str): "Make sure `df[field_name]` is of the right date type." field_dtype = df[date_field].dtype if isinstance(field_dtype, pd.core.dtypes.dtypes.DatetimeTZDtype): field_dtype = np.datetime64 if not np.issubdtype...
[]
Please provide a description of the function:def cyclic_dt_feat_names(time:bool=True, add_linear:bool=False)->List[str]: "Return feature names of date/time cycles as produced by `cyclic_dt_features`." fs = ['cos','sin'] attr = [f'{r}_{f}' for r in 'weekday day_month month_year day_year'.split() for f in fs]...
[]
Please provide a description of the function:def cyclic_dt_features(d:Union[date,datetime], time:bool=True, add_linear:bool=False)->List[float]: "Calculate the cos and sin of date/time cycles." tt,fs = d.timetuple(), [np.cos, np.sin] day_year,days_month = tt.tm_yday, calendar.monthrange(d.year, d.month)[1] ...
[]
Please provide a description of the function:def add_cyclic_datepart(df:DataFrame, field_name:str, prefix:str=None, drop:bool=True, time:bool=False, add_linear:bool=False): "Helper function that adds trigonometric date/time features to a date in the column `field_name` of `df`." make_date(df, field_name) fi...
[]
Please provide a description of the function:def add_datepart(df:DataFrame, field_name:str, prefix:str=None, drop:bool=True, time:bool=False): "Helper function that adds columns relevant to a date in the column `field_name` of `df`." make_date(df, field_name) field = df[field_name] prefix = ifnone(prefi...
[]
Please provide a description of the function:def cont_cat_split(df, max_card=20, dep_var=None)->Tuple[List,List]: "Helper function that returns column names of cont and cat variables from given df." cont_names, cat_names = [], [] for label in df: if label == dep_var: continue if df[label].dt...
[]
Please provide a description of the function:def apply_train(self, df:DataFrame): "Transform `self.cat_names` columns in categorical." self.categories = {} for n in self.cat_names: df.loc[:,n] = df.loc[:,n].astype('category').cat.as_ordered() self.categories[n] = df[n].ca...
[]
Please provide a description of the function:def apply_train(self, df:DataFrame): "Compute the means and stds of `self.cont_names` columns to normalize them." self.means,self.stds = {},{} for n in self.cont_names: assert is_numeric_dtype(df[n]), (f) self.means[n],self.std...
[ "Cannot normalize '{n}' column as it isn't numerical.\n Are you sure it doesn't belong in the categorical set of columns?" ]
Please provide a description of the function:def def_emb_sz(classes, n, sz_dict=None): "Pick an embedding size for `n` depending on `classes` if not given in `sz_dict`." sz_dict = ifnone(sz_dict, {}) n_cat = len(classes[n]) sz = sz_dict.get(n, int(emb_sz_rule(n_cat))) # rule of thumb return n_cat,s...
[]
Please provide a description of the function:def tabular_learner(data:DataBunch, layers:Collection[int], emb_szs:Dict[str,int]=None, metrics=None, ps:Collection[float]=None, emb_drop:float=0., y_range:OptRange=None, use_bn:bool=True, **learn_kwargs): "Get a `Learner` using `data`, with `metrics`, including ...
[]
Please provide a description of the function:def from_df(cls, path, df:DataFrame, dep_var:str, valid_idx:Collection[int], procs:OptTabTfms=None, cat_names:OptStrList=None, cont_names:OptStrList=None, classes:Collection=None, test_df=None, bs:int=64, val_bs:int=None, num_workers:int=defa...
[]
Please provide a description of the function:def from_df(cls, df:DataFrame, cat_names:OptStrList=None, cont_names:OptStrList=None, procs=None, **kwargs)->'ItemList': "Get the list of inputs in the `col` of `path/csv_name`." return cls(items=range(len(df)), cat_names=cat_names, cont_names=cont_names, pro...
[]
Please provide a description of the function:def get_emb_szs(self, sz_dict=None): "Return the default embedding sizes suitable for this data or takes the ones in `sz_dict`." return [def_emb_sz(self.classes, n, sz_dict) for n in self.cat_names]
[]
Please provide a description of the function:def show_xys(self, xs, ys)->None: "Show the `xs` (inputs) and `ys` (targets)." from IPython.display import display, HTML items,names = [], xs[0].names + ['target'] for i, (x,y) in enumerate(zip(xs,ys)): res = [] cats = ...
[]
Please provide a description of the function:def load_model(itos_filename, classifier_filename, num_classes): # load the int to string mapping file itos = pickle.load(Path(itos_filename).open('rb')) # turn it into a string to int mapping (which is what we need) stoi = collections.defaultdict(lambd...
[ "Load the classifier and int to string mapping\n\n Args:\n itos_filename (str): The filename of the int to string mapping file (usually called itos.pkl)\n classifier_filename (str): The filename of the trained classifier\n\n Returns:\n string to int mapping, trained classifer model\n "...
Please provide a description of the function:def softmax(x): ''' Numpy Softmax, via comments on https://gist.github.com/stober/1946926 >>> res = softmax(np.array([0, 200, 10])) >>> np.sum(res) 1.0 >>> np.all(np.abs(res - np.array([0, 1, 0])) < 0.0001) True >>> res = softmax(np.array([[0...
[]
Please provide a description of the function:def predict_text(stoi, model, text): # prefix text with tokens: # xbos: beginning of sentence # xfld 1: we are using a single field here input_str = 'xbos xfld 1 ' + text # predictions are done on arrays of input. # We only have a single in...
[ "Do the actual prediction on the text using the\n model and mapping files passed\n " ]
Please provide a description of the function:def predict_input(itos_filename, trained_classifier_filename, num_classes=2): # Check the itos file exists if not os.path.exists(itos_filename): print("Could not find " + itos_filename) exit(-1) # Check the classifier file exists if not ...
[ "\n Loads a model and produces predictions on arbitrary input.\n :param itos_filename: the path to the id-to-string mapping file\n :param trained_classifier_filename: the filename of the trained classifier;\n typically ends with \"clas_1.h5\"\n :param num_classes: ...
Please provide a description of the function:def _make_w3c_caps(caps): caps = copy.deepcopy(caps) profile = caps.get('firefox_profile') always_match = {} if caps.get('proxy') and caps['proxy'].get('proxyType'): caps['proxy']['proxyType'] = caps['proxy']['proxyType'].lower() for k, v in ...
[ "Makes a W3C alwaysMatch capabilities object.\n\n Filters out capability names that are not in the W3C spec. Spec-compliant\n drivers will reject requests containing unknown capability names.\n\n Moves the Firefox profile, if present, from the old location to the new Firefox\n options object.\n\n :Ar...
Please provide a description of the function:def file_detector_context(self, file_detector_class, *args, **kwargs): last_detector = None if not isinstance(self.file_detector, file_detector_class): last_detector = self.file_detector self.file_detector = file_detector_clas...
[ "\n Overrides the current file detector (if necessary) in limited context.\n Ensures the original file detector is set afterwards.\n\n Example:\n\n with webdriver.file_detector_context(UselessFileDetector):\n someinput.send_keys('/etc/hosts')\n\n :Args:\n - file...
Please provide a description of the function:def start_session(self, capabilities, browser_profile=None): if not isinstance(capabilities, dict): raise InvalidArgumentException("Capabilities must be a dictionary") if browser_profile: if "moz:firefoxOptions" in capabilitie...
[ "\n Creates a new session with the desired capabilities.\n\n :Args:\n - browser_name - The name of the browser to request.\n - version - Which browser version to request.\n - platform - Which platform to request the browser on.\n - javascript_enabled - Whether the new s...
Please provide a description of the function:def create_web_element(self, element_id): return self._web_element_cls(self, element_id, w3c=self.w3c)
[ "Creates a web element with the specified `element_id`." ]
Please provide a description of the function:def execute(self, driver_command, params=None): if self.session_id is not None: if not params: params = {'sessionId': self.session_id} elif 'sessionId' not in params: params['sessionId'] = self.session_...
[ "\n Sends a command to be executed by a command.CommandExecutor.\n\n :Args:\n - driver_command: The name of the command to execute as a string.\n - params: A dictionary of named parameters to send with the command.\n\n :Returns:\n The command's JSON response loaded into...
Please provide a description of the function:def find_element_by_id(self, id_): return self.find_element(by=By.ID, value=id_)
[ "Finds an element by id.\n\n :Args:\n - id\\\\_ - The id of the element to be found.\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ::\n\n ele...
Please provide a description of the function:def find_elements_by_id(self, id_): return self.find_elements(by=By.ID, value=id_)
[ "\n Finds multiple elements by id.\n\n :Args:\n - id\\\\_ - The id of the elements to be found.\n\n :Returns:\n - list of WebElement - a list with elements if any was found. An\n empty list if not\n\n :Usage:\n ::\n\n elements = driver...
Please provide a description of the function:def find_element_by_xpath(self, xpath): return self.find_element(by=By.XPATH, value=xpath)
[ "\n Finds an element by xpath.\n\n :Args:\n - xpath - The xpath locator of the element to find.\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ::\n\n ...
Please provide a description of the function:def find_elements_by_xpath(self, xpath): return self.find_elements(by=By.XPATH, value=xpath)
[ "\n Finds multiple elements by xpath.\n\n :Args:\n - xpath - The xpath locator of the elements to be found.\n\n :Returns:\n - list of WebElement - a list with elements if any was found. An\n empty list if not\n\n :Usage:\n ::\n\n eleme...
Please provide a description of the function:def find_element_by_link_text(self, link_text): return self.find_element(by=By.LINK_TEXT, value=link_text)
[ "\n Finds an element by link text.\n\n :Args:\n - link_text: The text of the element to be found.\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ::\n\...
Please provide a description of the function:def find_elements_by_link_text(self, text): return self.find_elements(by=By.LINK_TEXT, value=text)
[ "\n Finds elements by link text.\n\n :Args:\n - link_text: The text of the elements to be found.\n\n :Returns:\n - list of webelement - a list with elements if any was found. an\n empty list if not\n\n :Usage:\n ::\n\n elements = drive...
Please provide a description of the function:def find_element_by_partial_link_text(self, link_text): return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text)
[ "\n Finds an element by a partial match of its link text.\n\n :Args:\n - link_text: The text of the element to partially match on.\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n ...
Please provide a description of the function:def find_elements_by_partial_link_text(self, link_text): return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text)
[ "\n Finds elements by a partial match of their link text.\n\n :Args:\n - link_text: The text of the element to partial match on.\n\n :Returns:\n - list of webelement - a list with elements if any was found. an\n empty list if not\n\n :Usage:\n ::\n\n...
Please provide a description of the function:def find_element_by_name(self, name): return self.find_element(by=By.NAME, value=name)
[ "\n Finds an element by name.\n\n :Args:\n - name: The name of the element to find.\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ::\n\n ...
Please provide a description of the function:def find_elements_by_name(self, name): return self.find_elements(by=By.NAME, value=name)
[ "\n Finds elements by name.\n\n :Args:\n - name: The name of the elements to find.\n\n :Returns:\n - list of webelement - a list with elements if any was found. an\n empty list if not\n\n :Usage:\n ::\n\n elements = driver.find_element...
Please provide a description of the function:def find_element_by_tag_name(self, name): return self.find_element(by=By.TAG_NAME, value=name)
[ "\n Finds an element by tag name.\n\n :Args:\n - name - name of html tag (eg: h1, a, span)\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ::\n\n ...
Please provide a description of the function:def find_elements_by_tag_name(self, name): return self.find_elements(by=By.TAG_NAME, value=name)
[ "\n Finds elements by tag name.\n\n :Args:\n - name - name of html tag (eg: h1, a, span)\n\n :Returns:\n - list of WebElement - a list with elements if any was found. An\n empty list if not\n\n :Usage:\n ::\n\n elements = driver.find_e...
Please provide a description of the function:def find_element_by_class_name(self, name): return self.find_element(by=By.CLASS_NAME, value=name)
[ "\n Finds an element by class name.\n\n :Args:\n - name: The class name of the element to find.\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ::\n\n ...
Please provide a description of the function:def find_elements_by_class_name(self, name): return self.find_elements(by=By.CLASS_NAME, value=name)
[ "\n Finds elements by class name.\n\n :Args:\n - name: The class name of the elements to find.\n\n :Returns:\n - list of WebElement - a list with elements if any was found. An\n empty list if not\n\n :Usage:\n ::\n\n elements = driver....
Please provide a description of the function:def find_element_by_css_selector(self, css_selector): return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
[ "\n Finds an element by css selector.\n\n :Args:\n - css_selector - CSS selector string, ex: 'a.nav#home'\n\n :Returns:\n - WebElement - the element if it was found\n\n :Raises:\n - NoSuchElementException - if the element wasn't found\n\n :Usage:\n ...
Please provide a description of the function:def find_elements_by_css_selector(self, css_selector): return self.find_elements(by=By.CSS_SELECTOR, value=css_selector)
[ "\n Finds elements by css selector.\n\n :Args:\n - css_selector - CSS selector string, ex: 'a.nav#home'\n\n :Returns:\n - list of WebElement - a list with elements if any was found. An\n empty list if not\n\n :Usage:\n ::\n\n elements ...
Please provide a description of the function:def execute_script(self, script, *args): converted_args = list(args) command = None if self.w3c: command = Command.W3C_EXECUTE_SCRIPT else: command = Command.EXECUTE_SCRIPT return self.execute(command,...
[ "\n Synchronously Executes JavaScript in the current window/frame.\n\n :Args:\n - script: The JavaScript to execute.\n - \\\\*args: Any applicable arguments for your JavaScript.\n\n :Usage:\n ::\n\n driver.execute_script('return document.title;')\n ...
Please provide a description of the function:def execute_async_script(self, script, *args): converted_args = list(args) if self.w3c: command = Command.W3C_EXECUTE_SCRIPT_ASYNC else: command = Command.EXECUTE_ASYNC_SCRIPT return self.execute(command, { ...
[ "\n Asynchronously Executes JavaScript in the current window/frame.\n\n :Args:\n - script: The JavaScript to execute.\n - \\\\*args: Any applicable arguments for your JavaScript.\n\n :Usage:\n ::\n\n script = \"var callback = arguments[arguments.length ...
Please provide a description of the function:def quit(self): try: self.execute(Command.QUIT) finally: self.stop_client() self.command_executor.close()
[ "\n Quits the driver and closes every associated window.\n\n :Usage:\n ::\n\n driver.quit()\n " ]
Please provide a description of the function:def current_window_handle(self): if self.w3c: return self.execute(Command.W3C_GET_CURRENT_WINDOW_HANDLE)['value'] else: return self.execute(Command.GET_CURRENT_WINDOW_HANDLE)['value']
[ "\n Returns the handle of the current window.\n\n :Usage:\n ::\n\n driver.current_window_handle\n " ]
Please provide a description of the function:def window_handles(self): if self.w3c: return self.execute(Command.W3C_GET_WINDOW_HANDLES)['value'] else: return self.execute(Command.GET_WINDOW_HANDLES)['value']
[ "\n Returns the handles of all windows within the current session.\n\n :Usage:\n ::\n\n driver.window_handles\n " ]
Please provide a description of the function:def maximize_window(self): params = None command = Command.W3C_MAXIMIZE_WINDOW if not self.w3c: command = Command.MAXIMIZE_WINDOW params = {'windowHandle': 'current'} self.execute(command, params)
[ "\n Maximizes the current window that webdriver is using\n " ]
Please provide a description of the function:def get_cookie(self, name): if self.w3c: try: return self.execute(Command.GET_COOKIE, {'name': name})['value'] except NoSuchCookieException: return None else: cookies = self.get_cook...
[ "\n Get a single cookie by name. Returns the cookie if found, None if not.\n\n :Usage:\n ::\n\n driver.get_cookie('my_cookie')\n " ]
Please provide a description of the function:def implicitly_wait(self, time_to_wait): if self.w3c: self.execute(Command.SET_TIMEOUTS, { 'implicit': int(float(time_to_wait) * 1000)}) else: self.execute(Command.IMPLICIT_WAIT, { 'ms': float(t...
[ "\n Sets a sticky timeout to implicitly wait for an element to be found,\n or a command to complete. This method only needs to be called one\n time per session. To set the timeout for calls to\n execute_async_script, see set_script_timeout.\n\n :Args:\n - time_to_...
Please provide a description of the function: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': f...
[ "\n Set the amount of time that the script should wait during an\n execute_async_script call before throwing an error.\n\n :Args:\n - time_to_wait: The amount of time to wait (in seconds)\n\n :Usage:\n ::\n\n driver.set_script_timeout(30)\n " ]
Please provide a description of the function: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, { ...
[ "\n Set the amount of time to wait for a page load to complete\n before throwing an error.\n\n :Args:\n - time_to_wait: The amount of time to wait\n\n :Usage:\n ::\n\n driver.set_page_load_timeout(30)\n " ]
Please provide a description of the function:def find_element(self, by=By.ID, value=None): if self.w3c: if by == By.ID: by = By.CSS_SELECTOR value = '[id="%s"]' % value elif by == By.TAG_NAME: by = By.CSS_SELECTOR elif ...
[ "\n Find an element given a By strategy and locator. Prefer the find_element_by_* methods when\n possible.\n\n :Usage:\n ::\n\n element = driver.find_element(By.ID, 'foo')\n\n :rtype: WebElement\n " ]
Please provide a description of the function:def find_elements(self, by=By.ID, value=None): if self.w3c: if by == By.ID: by = By.CSS_SELECTOR value = '[id="%s"]' % value elif by == By.TAG_NAME: by = By.CSS_SELECTOR elif...
[ "\n Find elements given a By strategy and locator. Prefer the find_elements_by_* methods when\n possible.\n\n :Usage:\n ::\n\n elements = driver.find_elements(By.CLASS_NAME, 'foo')\n\n :rtype: list of WebElement\n " ]
Please provide a description of the function: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) ...
[ "\n Saves a screenshot of the current window to a PNG image file. Returns\n False if there is any IOError, else returns True. Use full paths in\n your filename.\n\n :Args:\n - filename: The full path you wish to save your screenshot to. This\n should end with a `....
Please provide a description of the function:def set_window_size(self, width, height, windowHandle='current'): if self.w3c: if windowHandle != 'current': warnings.warn("Only 'current' window is supported for W3C compatibile browsers.") self.set_window_rect(width=...
[ "\n Sets the width and height of the current window. (window.resizeTo)\n\n :Args:\n - width: the width in pixels to set the window to\n - height: the height in pixels to set the window to\n\n :Usage:\n ::\n\n driver.set_window_size(800,600)\n " ]
Please provide a description of the function: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.") ...
[ "\n Gets the width and height of the current window.\n\n :Usage:\n ::\n\n driver.get_window_size()\n " ]
Please provide a description of the function:def set_window_position(self, x, y, windowHandle='current'): if self.w3c: if windowHandle != 'current': warnings.warn("Only 'current' window is supported for W3C compatibile browsers.") return self.set_window_rect(x=in...
[ "\n Sets the x,y position of the current window. (window.moveTo)\n\n :Args:\n - x: the x-coordinate in pixels to set the window position\n - y: the y-coordinate in pixels to set the window position\n\n :Usage:\n ::\n\n driver.set_window_position(0,0)\n ...
Please provide a description of the function: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() ...
[ "\n Gets the x,y position of the current window.\n\n :Usage:\n ::\n\n driver.get_window_position()\n " ]
Please provide a description of the function: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...
[ "\n Sets the x, y coordinates of the window as well as height and width of\n the current window. This method is only supported for W3C compatible\n browsers; other browsers should use `set_window_position` and\n `set_window_size`.\n\n :Usage:\n ::\n\n dri...
Please provide a description of the function: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 ...
[ "\n Set the file detector to be used when sending keyboard input.\n By default, this is set to a file detector that does nothing.\n\n see FileDetector\n see LocalFileDetector\n see UselessFileDetector\n\n :Args:\n - detector: The detector to use. Must not be None.\n...
Please provide a description of the function: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 ...
[ "\n Sets the current orientation of the device\n\n :Args:\n - value: orientation to set it to.\n\n :Usage:\n ::\n\n driver.orientation = 'landscape'\n " ]
Please provide a description of the function:def check_response(self, response): status = response.get('status', None) if status is None or status == ErrorCode.SUCCESS: return value = None message = response.get("message", "") screen = response.get("screen", ...
[ "\n Checks that a JSON response from the WebDriver does not have an error.\n\n :Args:\n - response - The JSON response from the WebDriver server as a dictionary\n object.\n\n :Raises: If the response contains an error message.\n " ]
Please provide a description of the function:def until(self, method, message=''): screen = None stacktrace = None end_time = time.time() + self._timeout while True: try: value = method(self._driver) if value: retur...
[ "Calls the method provided with the driver as an argument until the \\\n return value does not evaluate to ``False``.\n\n :param method: callable(WebDriver)\n :param message: optional message for :exc:`TimeoutException`\n :returns: the result of the last call to `method`\n :raises...
Please provide a description of the function: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_...
[ "Calls the method provided with the driver as an argument until the \\\n return value evaluates to ``False``.\n\n :param method: callable(WebDriver)\n :param message: optional message for :exc:`TimeoutException`\n :returns: the result of the last call to `method`, or\n `...
Please provide a description of the function: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:...
[ "Quits the driver and close every associated window." ]
Please provide a description of the function: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\n a `with` statement. The state of the context on the server is\n saved before entering the block, and restored upon exiting it.\n\n :param context: Context, may be one of the class properties\n `CONTEXT_CHROME` or `CONTEX...
Please provide a description of the function: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"]
[ "\n Installs Firefox addon.\n\n Returns identifier of installed addon. This identifier can later\n be used to uninstall addon.\n\n :param path: Absolute path to the addon that will be installed.\n\n :Usage:\n ::\n\n driver.install_addon('/path/to/firebug....
Please provide a description of the function: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\n ``FirefoxBinary`` instance.\n\n " ]
Please provide a description of the function: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\n or ``FirefoxProfile``.\n\n " ]
Please provide a description of the function:def headless(self, value): if value is True: self._arguments.append('-headless') elif '-headless' in self._arguments: self._arguments.remove('-headless')
[ "\n Sets the headless argument\n\n Args:\n value: boolean value indicating to set the headless option\n " ]
Please provide a description of the function:def to_capabilities(self): # This intentionally looks at the internal properties # so if a binary or profile has _not_ been set, # it will defer to geckodriver to find the system Firefox # and generate a fresh profile. caps = ...
[ "Marshals the Firefox options to a `moz:firefoxOptions`\n object.\n " ]
Please provide a description of the function: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_co...
[ "\n Set the network connection for the remote device.\n\n Example of setting airplane mode::\n\n driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)\n " ]
Please provide a description of the function: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 ...
[ "Unzip zipfile to a temporary directory.\n\n The directory of the unzipped files is returned if success,\n otherwise None is returned. " ]
Please provide a description of the function:def tap(self, on_element): self._actions.append(lambda: self._driver.execute( Command.SINGLE_TAP, {'element': on_element.id})) return self
[ "\n Taps on a given element.\n\n :Args:\n - on_element: The element to tap.\n " ]
Please provide a description of the function:def double_tap(self, on_element): self._actions.append(lambda: self._driver.execute( Command.DOUBLE_TAP, {'element': on_element.id})) return self
[ "\n Double taps on a given element.\n\n :Args:\n - on_element: The element to tap.\n " ]
Please provide a description of the function: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
[ "\n Touch down at given coordinates.\n\n :Args:\n - xcoord: X Coordinate to touch down.\n - ycoord: Y Coordinate to touch down.\n " ]
Please provide a description of the function:def move(self, xcoord, ycoord): self._actions.append(lambda: self._driver.execute( Command.TOUCH_MOVE, { 'x': int(xcoord), 'y': int(ycoord)})) return self
[ "\n Move held tap to specified location.\n\n :Args:\n - xcoord: X Coordinate to move.\n - ycoord: Y Coordinate to move.\n " ]
Please provide a description of the function:def release(self, xcoord, ycoord): self._actions.append(lambda: self._driver.execute( Command.TOUCH_UP, { 'x': int(xcoord), 'y': int(ycoord)})) return self
[ "\n Release previously issued tap 'and hold' command at specified location.\n\n :Args:\n - xcoord: X Coordinate to release.\n - ycoord: Y Coordinate to release.\n " ]
Please provide a description of the function:def scroll(self, xoffset, yoffset): self._actions.append(lambda: self._driver.execute( Command.TOUCH_SCROLL, { 'xoffset': int(xoffset), 'yoffset': int(yoffset)})) return self
[ "\n Touch and scroll, moving by xoffset and yoffset.\n\n :Args:\n - xoffset: X offset to scroll to.\n - yoffset: Y offset to scroll to.\n " ]
Please provide a description of the function: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': ...
[ "\n Touch and scroll starting at on_element, moving by xoffset and yoffset.\n\n :Args:\n - on_element: The element where scroll starts.\n - xoffset: X offset to scroll to.\n - yoffset: Y offset to scroll to.\n " ]
Please provide a description of the function:def long_press(self, on_element): self._actions.append(lambda: self._driver.execute( Command.LONG_PRESS, {'element': on_element.id})) return self
[ "\n Long press on an element.\n\n :Args:\n - on_element: The element to long press.\n " ]
Please provide a description of the function:def flick(self, xspeed, yspeed): self._actions.append(lambda: self._driver.execute( Command.FLICK, { 'xspeed': int(xspeed), 'yspeed': int(yspeed)})) return self
[ "\n Flicks, starting anywhere on the screen.\n\n :Args:\n - xspeed: The X speed in pixels per second.\n - yspeed: The Y speed in pixels per second.\n " ]
Please provide a description of the function: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(yo...
[ "\n Flick starting at on_element, and moving by the xoffset and yoffset\n with specified speed.\n\n :Args:\n - on_element: Flick will start at center of element.\n - xoffset: X offset to flick to.\n - yoffset: Y offset to flick to.\n - speed: Pixels per second to...