css-selectors

Next-sibling combinator should not work with complex selectors

落爺英雄遲暮 提交于 2021-02-05 05:50:28
问题 TL;DR According to the spec the following should not work but it does: .a .b + .b {margin-top:20px;} Details According to the spec the "Next-sibling combinator" (or "adjacent sibling combinator") should only work for "sequences of simple selectors", which themselves are defined as ... a chain of simple selectors that are not separated by a combinator. In my example given above, the selector .a .b to the left contains a "descendant combinator" (represented by whitespace) and should therefore

CSS selector to match elements by attribute's name start

那年仲夏 提交于 2021-02-04 22:13:57
问题 Is there any CSS selector to match these elements? (I need it for adblocker config, looked at W3C selectors document - no hints found there. Generic solution needed because part after data-d- gets randomized by the site ). <div data-d-9y3x> <div data-d-m01> <div data-d-whatever> 回答1: No, there is currently no way to select elements based on the presence of an attribute whose name is starting with a certain value. The starts with selection is only possible for attribute values. Such a selector

CSS selector to match elements by attribute's name start

拜拜、爱过 提交于 2021-02-04 22:11:27
问题 Is there any CSS selector to match these elements? (I need it for adblocker config, looked at W3C selectors document - no hints found there. Generic solution needed because part after data-d- gets randomized by the site ). <div data-d-9y3x> <div data-d-m01> <div data-d-whatever> 回答1: No, there is currently no way to select elements based on the presence of an attribute whose name is starting with a certain value. The starts with selection is only possible for attribute values. Such a selector

CSS selector QuerySelector alternative

醉酒当歌 提交于 2021-02-04 21:41:04
问题 I have searched a lot and a lot so as to find material about how to get meta data using XMLHTTP. And I think that's impossible to do that using the Early binding method. The only approach that will work is the late binding by CreateObject("HTMLFile") and dealing with that HTML which is late binding. The disadvantage of this approach is that it doesn't support the use of the QuerySelector or QuerySelectorAll .. Now I am trying to find alternative to this CSS selector .. without using the

How to extract all href from a class in Python Selenium?

自作多情 提交于 2021-02-04 20:48:09
问题 I am trying to extract people's href from the URL https://www.dx3canada.com/agenda/speakers. I tried: elems = driver.find_elements_by_css_selector('.display-flex card vancouver') href_output = [] for ele in elems: href_output.append(ele.get_attribute("href")) print(href_output) But the output list returns nothing... The expected href shown as the image below and I hope the outputs as a list of hrefs: I really appreciate the help! 回答1: To extract the people's href attribute from the URL https:

How to target all elements besides the first with nth-child?

人盡茶涼 提交于 2021-02-04 15:30:33
问题 How do I target all paragraphs inside a given DIV beside the first one using the :nth-child operator? :nth-child(/* select all but the first one */) { color: green; } <div> <p>Example 1</p> <p>Example 2</p> <p>Example 3</p> <p>Example 4</p> <p>Example 5</p> <p>Example 6</p> <p>Example 7</p> </div> 回答1: You can use the following formula: :nth-child(n+1) or for some browsers: :nth-child(n+2) W3Schools says: Using a formula (an + b). Description: a represents a cycle size, n is a counter (starts

How to target all elements besides the first with nth-child?

此生再无相见时 提交于 2021-02-04 15:30:01
问题 How do I target all paragraphs inside a given DIV beside the first one using the :nth-child operator? :nth-child(/* select all but the first one */) { color: green; } <div> <p>Example 1</p> <p>Example 2</p> <p>Example 3</p> <p>Example 4</p> <p>Example 5</p> <p>Example 6</p> <p>Example 7</p> </div> 回答1: You can use the following formula: :nth-child(n+1) or for some browsers: :nth-child(n+2) W3Schools says: Using a formula (an + b). Description: a represents a cycle size, n is a counter (starts

Finding link using text in CSS Selector is not working

╄→гoц情女王★ 提交于 2021-02-04 08:38:08
问题 I am trying to locate below link by using a[text='This is a link'] and a[innertext='This is a link'] but both of them are not working. I know this can be achieved by using XPath or other ways, but I am curious why CSS Selector that I have used is not working. refer this link. <a title="seleniumframework" href="http://www.seleniumframework.com" target="_blank">This is a link</a> 回答1: You are trying to locate a link by using the following CssSelector s: a[text='This is a link'] a[innertext=

Selenium won't type to textarea and raises ElementNotInteractableException

大憨熊 提交于 2021-02-04 08:28:27
问题 This is the HTML code in question: <textarea rows="1" cols="1" name="text" class=""></textarea> This is my code: msgElem = driver.find_element_by_css_selector("textarea[name='text']") driver.execute_script("arguments[0].click();", msgElem) driver.execute_script("arguments[0].value = 'Whats up mate, how you doin';", msgElem) msgElem.submit() The code executes and nothing happens. I assume it selects the textarea but doesn't type nothing into it? or nothing happens at all. It also finds the

How to solve a StaleElementReferenceException: Message: stale element reference: element is not attached error using Selenium Ubuntu EC2 using Python

余生颓废 提交于 2021-02-04 08:27:30
问题 I am trying to extract all data of column "Nb B" in this page : https://www.coteur.com/cotes-foot.php When I run my code from a Ubuntu PC It works perfectly but when I tried with EC2 Ubuntu It does not give me the good return. Here is my server : ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200611 (ami-0a63f96e85105c6d3) Here is the python script : #!/usr/bin/python3 # -*- coding: utf­-8 ­-*- from selenium import webdriver from selenium.webdriver.chrome.options import Options