10 examples of 'python selenium css selector' in Python

Every line of 'python selenium css selector' 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
this disclaimer
254def get_element_by_xpath(self, selector):
255 """
256 Gets an element using an xPath selector.
257 """
258 raise NotImplementedError(
259 "This browser doesn't support getting elements by xpath")
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

37def find_css(self, css_selector, prefix=True, force_list=False, fail=True):
38 """Shortcut to find elements by CSS. Returns either a list or singleton."""
39 if prefix and self.css_prefix:
40 css_selector = '{0.css_prefix} {1}'.format(self, css_selector)
41 return self.web_driver.find_css(css_selector, force_list=force_list, fail=fail)
200def css(self, selector):
201 """
202 An alias for :class:`zombie.dom.DOMNode.queryAll`.
203 """
204 return self.queryAll(selector)
100def click(self, selector):
101 self.element(selector).click()
172def FindCss(self, css, obj=None):
173 """Find web element using CSS elements.
174
175 Args:
176 css: string, css element to search for.
177 obj: web element object to search within.
178 Returns:
179 web element object that contains css.
180 """
181 try:
182 self.GetWait().until(EC.presence_of_element_located((By.CSS_SELECTOR, css)))
183 except TimeoutException:
184 self.logger.error('Timed out waiting for css: %s', css)
185 return None
186 else:
187 try:
188 if obj:
189 element = obj.find_element_by_css_selector(css)
190 else:
191 element = self.driver.find_element_by_css_selector(css)
192 except NoSuchElementException:
193 self.logger.error('Element css %s not found', css)
194 return None
195 return element
72def all(self, css_or_xpath_or_by: Union[str, tuple]) -> Collection:
73 by = to_by(css_or_xpath_or_by)
74
75 return Collection(
76 Locator(f'{self}.all({by})',
77 lambda: self().find_elements(*by)),
78 self.config)
69def find_element(self, *selector):
70 """
71 之前这里设计的太复杂,将其改为传入元组
72 传入的时候定义好定位的方式和元素
73 """
74 try:
75 element = self.driver.find_element(*selector)
76 logger.info("The element looked up is %s "% (selector))
77 return element
78 except NoSuchElementException as e:
79 logger.error("NoSuchElementException: %s" % e)
80 self.get_windows_img()
156def css(self):
157 """ str: The CSS query for this selector. """
158 return self.expression
35def _elements(self, css_selector):
36 return self.root.find_elements_by_css_selector(css_selector)
115def xpath_selected_pseudo(self, xpath):
116 """Matches all elements that are selected::
117
118 >>> from pyquery import PyQuery
119 >>> d = PyQuery('<select><option selected="selected"/></select>')
120 >>> d('option:selected')
121 [<option>]
122
123 ..
124 """
125 xpath.add_condition("@selected and name(.) = 'option'")
126 return xpath

Related snippets