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

Every line of 'find element by class name 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)
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)
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)
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
5def find_element(driver, locator):
6 return WebDriverWait(driver, 2).until(
7 EC.presence_of_element_located(locator))
54def find_by_text(self, tag, text):
55 return self.wait_until_visible((By.XPATH,"//" + tag + "[contains(.,'" + text + "')]"))
120def find_element_by_link_text(self, *args, **kwargs):
121 return self.__getattr_from_webdriver_or_webelement__('find_element_by_link_text')(*args, **kwargs)
34def find_element_by_name(self, name):
35 web_element = super(WebChrome, self).find_element_by_name(name)
36 self.gen_screen_log(web_element)
37 return Element(web_element)
972def select_by_id(self, element_id, text='', index=-1, timeout_in_seconds=None):
973 """
974 Selects element with particular text on it.
975 :param element_id:
976 :param text:
977 """
978 print "Executing select_by_id id = {0}, text = {1}".format(element_id, text)
979 self.wait_for_text_present_by_id(element_id, text, timeout_in_seconds=timeout_in_seconds)
980 if index == -1:
981 print "Selecting element with text = {1} by id = {0}".format(element_id, text)
982 Select(self.driver.find_element_by_id(element_id)).select_by_visible_text(text)
983 else:
984 print "Selecting element with index = {1} by id = {0}".format(element_id, index)
985 Select(self.driver.find_element_by_id(element_id)).select_by_index(index)

Related snippets