10 examples of 'find element by class selenium python' in Python

Every line of 'find element by class selenium python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
99def find_element_by_class_name(self, class_name):
100 """
101 Find an element in the DOM by class name.
102
103 Args:
104 class_name:
105
106 Returns:
107 WebElement
108 """
109 ele = self.soup.find(attrs={'class': class_name})
110 if ele is None:
111 raise NoSuchElementException('The element could not be located by class name: {}'.format(class_name))
112
113 return WebElement(ele, self.current_response, self.current_url, parent=self.id)
5def find_element(driver, locator):
6 return WebDriverWait(driver, 2).until(
7 EC.presence_of_element_located(locator))
702def __get_class__(self, class_name, as_list=True, timeout=Global.large_min):
703 wait = WebDriverWait(self.driver, timeout)
704 wait.until(ec.presence_of_element_located((By.CLASS_NAME, class_name)))
705 if as_list:
706 return self.driver.find_elements_by_class_name(class_name)
707 else:
708 return self.driver.find_element_by_class_name(class_name)
120def find_element_by_link_text(self, *args, **kwargs):
121 return self.__getattr_from_webdriver_or_webelement__('find_element_by_link_text')(*args, **kwargs)
54def find_by_text(self, tag, text):
55 return self.wait_until_visible((By.XPATH,"//" + tag + "[contains(.,'" + text + "')]"))
98def find_element_by_tag_name(self, tag_name):
99 return self.browser.find_element_by_tag_name(tag_name)
146def FindClasses(self, classname, obj=None):
147 """Find all web elements with classname.
148
149 Args:
150 classname: string, class to search for.
151 obj: web element object to search within.
152 Returns:
153 list of web element objects containing classname.
154 """
155 try:
156 self.GetWait().until(EC.presence_of_all_elements_located((By.CLASS_NAME,
157 classname)))
158 except TimeoutException:
159 self.logger.error('Timed out looking for class: %s', classname)
160 return None
161 else:
162 try:
163 if obj:
164 elements = obj.find_elements_by_class_name(classname)
165 else:
166 elements = self.driver.find_elements_by_class_name(classname)
167 except NoSuchElementException:
168 self.logger.error('Error finding %s class name.', classname)
169 return None
170 return elements
497def find_elements_by_name(self, name):
498 """
499 Finds elements by name.
500
501 :Args:
502 - name: The name of the elements to find.
503
504 :Returns:
505 - list of webelement - a list with elements if any was found. an
506 empty list if not
507
508 :Usage:
509 elements = driver.find_elements_by_name('foo')
510 """
511 return self.find_elements(by=By.NAME, value=name)
18def finder(driver):
19 element = driver.find_element_by_class_name(element_class)
20 assert element.size['width'] == width
501def find_option_by_text(self, text):
502 return self.find_by_xpath(
503 '//option[normalize-space(text())="%s"]' % text,
504 original_find="option by text",
505 original_query=text,
506 )

Related snippets