css-selectors

querySelector vs. querySelectorAll

倖福魔咒の 提交于 2021-02-08 08:42:43
问题 I have some trouble in creating a selector in javascript. This is my code: function __(selector){ var self = {}; self.selector = selector; if(typeof selector == 'object'){ self.element = self.selector; }else{ self.element = document.querySelector(self.selector); } // make a .css method to an element self.css = function(propval){ return Object.assign(self.element.style,propval); } return self; } And my html file <script src="js/selector.js"></script> <script> window.onload = function(){ __('p'

Python Selenium CSS Selector by Span get_attribute

吃可爱长大的小学妹 提交于 2021-02-08 03:31:11
问题 I have already accessed a webpage, populated text boxes and drop downs with required parameters, and submitted (button click) this information so the webpage can perform a calculation. I am trying to access the results (value of text). Results should be a list of calculations listed least to greatest, and I only want the lowest value. I am not sure if I am having a timing issue or a CSS Selector issue. I have tried: e = driver.find_elements_by_css_selector("span[data-bind='calc']") new = e[0]

Python Selenium CSS Selector by Span get_attribute

纵饮孤独 提交于 2021-02-08 03:30:31
问题 I have already accessed a webpage, populated text boxes and drop downs with required parameters, and submitted (button click) this information so the webpage can perform a calculation. I am trying to access the results (value of text). Results should be a list of calculations listed least to greatest, and I only want the lowest value. I am not sure if I am having a timing issue or a CSS Selector issue. I have tried: e = driver.find_elements_by_css_selector("span[data-bind='calc']") new = e[0]

Finding elements by CSS selector with ChromeDriver (Selenium) in Python

允我心安 提交于 2021-02-08 03:06:54
问题 I'm using ChromeDriver of Selenium with Python and I'm trying to find a button on my page that has the following HTML: <input id="j_id0:SiteTemplate:j_id255:new" type="submit" name="j_id0:SiteTemplate:j_id255:new" value="New" class="kbutton-white"> The only thing I know being constant is the id and name ending with "new" and I'm trying to use the following code to identify and click that element: test_runner.driver.find_element_by_css_selector('[id*=new]').click() However, I get this error

Finding elements by CSS selector with ChromeDriver (Selenium) in Python

纵饮孤独 提交于 2021-02-08 03:01:32
问题 I'm using ChromeDriver of Selenium with Python and I'm trying to find a button on my page that has the following HTML: <input id="j_id0:SiteTemplate:j_id255:new" type="submit" name="j_id0:SiteTemplate:j_id255:new" value="New" class="kbutton-white"> The only thing I know being constant is the id and name ending with "new" and I'm trying to use the following code to identify and click that element: test_runner.driver.find_element_by_css_selector('[id*=new]').click() However, I get this error

Finding elements by CSS selector with ChromeDriver (Selenium) in Python

我的未来我决定 提交于 2021-02-08 03:00:51
问题 I'm using ChromeDriver of Selenium with Python and I'm trying to find a button on my page that has the following HTML: <input id="j_id0:SiteTemplate:j_id255:new" type="submit" name="j_id0:SiteTemplate:j_id255:new" value="New" class="kbutton-white"> The only thing I know being constant is the id and name ending with "new" and I'm trying to use the following code to identify and click that element: test_runner.driver.find_element_by_css_selector('[id*=new]').click() However, I get this error

Selenium find_elements_by_css_selector returns an empty list

拈花ヽ惹草 提交于 2021-02-07 21:37:48
问题 I'm trying to select all the ids which contain coupon-link keyword with the following script. from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get("http://udemycoupon.discountsglobal.com/coupon-category/free-2/") elems = driver.find_elements_by_css_selector('[id~=\"coupon-link\"]') print(elems) But I got an empty list [] as the result. What's wrong with my css_selector? I've tested that find_elements_by_css_selector('[id=\

Selenium find_elements_by_css_selector returns an empty list

守給你的承諾、 提交于 2021-02-07 21:37:13
问题 I'm trying to select all the ids which contain coupon-link keyword with the following script. from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get("http://udemycoupon.discountsglobal.com/coupon-category/free-2/") elems = driver.find_elements_by_css_selector('[id~=\"coupon-link\"]') print(elems) But I got an empty list [] as the result. What's wrong with my css_selector? I've tested that find_elements_by_css_selector('[id=\

CSS selector for text not in tags [duplicate]

假如想象 提交于 2021-02-07 20:25:51
问题 This question already has answers here : Is there a CSS selector for text nodes? (2 answers) Closed 5 years ago . I want to totally hide everything in the .byline except the date. Is it possible to do this via CSS w/o modifying the markup? Is there a CSS selector that allows you to target the inner text that's not in tags? <p class="byline"> By <a rel="author" href="#">John Doe</a> on <time datetime="2012-10-10" pubdate>2012</time> </p> This does not work b/c it hides the a but not the other

Selenium CSS selector for nth occurrence of td span:nth-child(2)

南笙酒味 提交于 2021-02-07 14:32:15
问题 The css selector td span:nth-child(2) means the 2nd child node span of td . I wanna choose the nth td span:nth-child(2) , something like: driver.find_element_by_css_selector("td span:nth-child(2):eq(4)") I know I can use driver.find_elements_by_css_selector("td span:nth-child(2)")[4] or xpath instead: driver.find_elements_by_xpath('(//td/span[2])[4]') I just wanna know if I can do the same thing with css selector. 回答1: You can't do this with a CSS selector. :eq() is from jQuery and not part