How to use wait_for_link_text method in SeleniumBase

Best Python code snippet using SeleniumBase

convert_ide.py

Source:convert_ide.py Github

copy

Full Screen

...591 uni = ""592 if '(u"' in line:593 uni = "u"594 link_text = data.group(1)595 command = '''%sself.wait_for_link_text(%s"%s")''' % (596 whitespace, uni, link_text)597 seleniumbase_lines.append(command)598 continue599 else:600 seleniumbase_lines.append(line)601 continue602 # Is there a Select() still present?603 lines = seleniumbase_lines604 for line_num in range(len(lines)):605 if "Select(self.driver" in lines[line_num]:606 uses_select = True607 # Remove duplicate functionality (wait_for_element)608 lines = seleniumbase_lines609 seleniumbase_lines = []...

Full Screen

Full Screen

_add.py

Source:_add.py Github

copy

Full Screen

1from pathlib import Path2from typing import Dict, Optional3import attr4from selenium.webdriver.common.by import By5from selenium.webdriver.support import expected_conditions6from selenium.webdriver.support.ui import Select, WebDriverWait7from gedmatch_tools.util import Kit, RawDataType8from gedmatch_tools.util import main_page9def _add(genotypes: Path,10 name: str,11 raw_data_type: Optional[RawDataType] = None,12 fam: Optional[Path] = None) -> Kit:13 '''Performs a generic upload of the given genotype.14 The sample information when given will be used to determine the sex of the donor, otherwise15 it will default to female.16 Args:17 genotypes: the path to the genotype file.18 name: the name of the donor.19 raw_data_type: optionally the raw data type to select.20 fam: optionally a PLINK sample information file; see the following link21 https://www.cog-genomics.org/plink2/formats#fam22 Returns:23 the kit created by GEDMatch24 Raises:25 Exception: if the kit could not be uploaded26 '''27 kit_number: str = ''28 fam_dict = _read_fam(fam) if fam is not None else {}29 driver = main_page()30 try:31 url = 'v_upload1.phpnf'32 page = driver.find_element_by_xpath('//a[@href="' + url + '"]')33 page.click()34 in_name = driver.find_element_by_name('name')35 in_name.clear()36 in_name.send_keys(name)37 male = False if name not in fam_dict or not fam_dict[name].sex else True38 if male:39 in_male = driver.find_element_by_css_selector(40 "input[type='radio'][value='M'][name='sex']")41 in_male.click()42 else:43 in_female = driver.find_element_by_css_selector(44 "input[type='radio'][value='F'][name='sex']")45 in_female.click()46 in_source = Select(driver.find_element_by_name('source'))47 in_source.select_by_index(21) # other48 raw_data_type_value = str(6 if raw_data_type is None else raw_data_type.value)49 in_auth = driver.find_element_by_css_selector(50 "input[type='radio'][value='" + raw_data_type_value + "'][name='auth']")51 in_auth.click()52 in_public = driver.find_element_by_css_selector(53 "input[type='radio'][value='Y'][name='public2']"54 )55 in_public.click()56 in_file = driver.find_element_by_css_selector(57 "input[type='file'][name='GedcomFile']")58 in_file.send_keys(str(genotypes.resolve()))59 submit = driver.find_element_by_css_selector(60 "input[type='submit'][name='gedsubmit']")61 submit.click()62 wait_for_link_text = 'Click here to get to Home'63 WebDriverWait(driver, 90).until(64 expected_conditions.visibility_of_element_located(65 (By.LINK_TEXT, wait_for_link_text)))66 for line in driver.page_source.split('\n'):67 if 'Assigned kit number:' in line:68 line = line.rstrip('\r\n').strip().replace('</font>', '')69 kit_number = line.split('>')[-1]70 break71 else:72 raise ValueError('No kit number returned by GEDmatch.')73 except Exception as e:74 print(driver.page_source)75 driver.close()76 raise e77 driver.close()78 return Kit(name=name, number=kit_number)79@attr.s80class _SampleInfo(object):81 '''Sample information'''82 family_id: str = attr.ib()83 sample_id: str = attr.ib()84 father_id: str = attr.ib()85 mother_id: str = attr.ib()86 sex: Optional[bool] = attr.ib()87 phenotype: str = attr.ib()88def _read_fam(fam: Path) -> Dict[str, _SampleInfo]:89 '''Reads a PLINK FAM file.90 Args:91 fam: the path to the FAM file.92 Returns:93 a dictionary of sample ids to sample information94 '''95 d: Dict[str, _SampleInfo] = dict()96 with open(fam, 'r') as fh:97 for line in fh:98 fields = line.rstrip('\r\n').split(' ')99 d[fields[1]] = _SampleInfo(100 family_id=fields[0],101 sample_id=fields[1],102 father_id=fields[2],103 mother_id=fields[3],104 sex=fields[4] == '1',105 phenotype=fields[5]106 )...

Full Screen

Full Screen

base.py

Source:base.py Github

copy

Full Screen

...24 except:25 raise ConnectorError(error_message)26 else:27 return element28 def wait_for_link_text(self, link_text, error_message, timeout=None):29 """ Wait for a link text to load """30 if not timeout:31 timeout = self.timeout32 try:33 element = WebDriverWait(self.driver, timeout).until(34 EC.presence_of_element_located((By.LINK_TEXT, link_text))35 )36 except:37 raise ConnectorError(error_message)38 else:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful