css-selectors

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

岁酱吖の 提交于 2021-02-07 14:27:27
问题 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

CSS Selector for nth element regardless of parent [duplicate]

。_饼干妹妹 提交于 2021-02-07 08:56:02
问题 This question already has an answer here : Matching the first/nth element of a certain type in the entire document (1 answer) Closed 4 years ago . Is there a CSS selector for the nth of a matching element, regardless of any parents. e.g. in the following how to select just "The second paragraph." without also the fourth one? <div> <p>The first paragraph.</p> <p>The second paragraph.</p> </div> <div> <p>The third paragraph.</p> <p>The fourth paragraph.</p> </div> I thought p:nth-oftype(2)

Python, Selenium find element with class and wait for class change

淺唱寂寞╮ 提交于 2021-02-07 07:26:45
问题 I have a web page which loads content dynamically and while page loads, there is spinning wheel, I already found solution to grab content loaded immediately on page, but seems i can't find solution to grab content loaded later in dom. What i can think of is to find element with specific class of that wheel spinning, and wait for it to change, once it's changed, than it means content is loaded in dom. I am using Selenium with Firefox webdriver on Ubuntu . Here is the class i am looking to

Using forward slash as ID attribute

本秂侑毒 提交于 2021-02-07 06:56:19
问题 Just discovered that you can use (any?) unicode character as ID attributes, and this opens up a whole new world for my part. But I'm trying to set the ID attribute to /name , and it doesn't want to work. Here's what I've got: http://jsfiddle.net/z2xkm9pr/ #\\/name\\/ { display:none; } #\\/name\\/:target { display: inline-block; } #\\/name\\/:target ~ .open { display: none; } What am I doing wrong? Or is this something impossible to achieve? Do I have to go back to using ☠ ? ALSO: In my final

CSS pseudo class for leaving hover

偶尔善良 提交于 2021-02-07 06:53:19
问题 I have a nice little hover effect on my website that quickly transitions in as the user hovers over a link. But when the user leaves hovering over the box, the shadow (and other traits) go away immediately, instead of fading back out. Is there a way I can get the properties to fade both in AND out, maybe using some sort of :un-hover type pseudo class? Thanks! And here is the CSS block if it helps: a.squares:hover, a.squares:active { color: black; background-color: #E8E8E8; box-shadow: 0 0

CSS pseudo class for leaving hover

萝らか妹 提交于 2021-02-07 06:53:15
问题 I have a nice little hover effect on my website that quickly transitions in as the user hovers over a link. But when the user leaves hovering over the box, the shadow (and other traits) go away immediately, instead of fading back out. Is there a way I can get the properties to fade both in AND out, maybe using some sort of :un-hover type pseudo class? Thanks! And here is the CSS block if it helps: a.squares:hover, a.squares:active { color: black; background-color: #E8E8E8; box-shadow: 0 0

CSS Selector to get the element attribute value

此生再无相见时 提交于 2021-02-06 10:50:45
问题 The HTML structure is like this: <td class='hey'> <a href="https://example.com">First one</a> </td> This is my selector: m_URL = sel.css("td.hey a:nth-child(1)[href] ").extract() My selector now will output <a href="https://example.com">First one</a> , but I only want it to output the link itself: https://example.com . How can I do that? 回答1: Get the ::attr(value) from the a tag. Demo (using Scrapy shell): $ scrapy shell index.html >>> response.css('td.hey a:nth-child(1)::attr(href)').extract

Differences between CSS3 :hover and :focus?

寵の児 提交于 2021-02-05 17:50:12
问题 The CSS3 doc talks about :hover and :focus, which seem exactly the same to me. What are the differences between the two? What am I not seeing? Thanks! 回答1: Hover is 'true' when the mouse pointer is over an element. Focus is true if the cursor is in that element. It's possible for hover to be false and focus true (e.g click in a text field then move the mouse away) 回答2: :hover applies to any element that the mouse cursor is currently over. :focus refers to form focus, and is the current form

Differences between CSS3 :hover and :focus?

孤人 提交于 2021-02-05 17:50:10
问题 The CSS3 doc talks about :hover and :focus, which seem exactly the same to me. What are the differences between the two? What am I not seeing? Thanks! 回答1: Hover is 'true' when the mouse pointer is over an element. Focus is true if the cursor is in that element. It's possible for hover to be false and focus true (e.g click in a text field then move the mouse away) 回答2: :hover applies to any element that the mouse cursor is currently over. :focus refers to form focus, and is the current form

How to print the partial text from an element using Selenium and Python

安稳与你 提交于 2021-02-05 09:27:45
问题 I am trying to get the text "Album Vol.1 [Every letter I sent you] LP (Normal Edition)" from http://www.ktown4u.com/iteminfo?grp_no=231307&goods_no=44363#dt_wrap01 under the description tab but I keep getting this error message. selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":".//div[@class='view_body']/div[2]/span"} Different variations give me similar error messages. driver.find_element_by_css_selector('