Questions tagged [css-selectors]

Selectors play a crucial role as they uniquely identify and target specific elements within a document tree. By incorporating selectors into a CSS rule, one can effectively establish customized styles for elements that perfectly align with the given pattern.

Finding the value within a div element with Selenium and Python

How can I extract the value inside a div using xpath or css_selector? This is the HTML markup: <div class="catalog-products view-tile" data-catalog-products="" data-slider-available="" data-primary-as-icon=""> ...

Using Python and Selenium to interact with dropdown menus in the browser

Being new to this, I've reviewed some of the examples provided here but despite their simplicity, I'm still struggling to make it work. The website I am trying to navigate is: www.webauto.de Below is my code for selecting a car make, model, and clicking ...

What is the alternative for * in CSS?

I have integrated a plugin into my project that necessitates the inclusion of the following code in its CSS file: *, *:after, *::before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } However, t ...

Element could not be found inside the pop-up dialog

I have been attempting to find those buttons displayed here: https://i.stack.imgur.com/5M1qd.png Here is the HTML for them: https://i.stack.imgur.com/238no.png I've experimented with different methods, but unfortunately, nothing has succeeded. ...

The Scrapy CSS selector is not fetching any prices from the list

Having trouble with the price CSS-selector while scraping an interactive website using Scrapy. Check out the HTML screenshot I captured: https://i.stack.imgur.com/oxULz.png Here are a few selectors that I've already experimented with: price = respon ...

CSS - Customizing the appearance of consecutive child divs

I'm struggling with adjusting the margin between two child divs when they follow each other. The current margin is set at 3rem, but I want it to be 1rem if both child containers have the class "narrow": Is there a way to achieve this without changing ...

A guide on utilizing Selenium to choose an option within a dropdown menu featuring an AJAX onchange attribute

After browsing several pages on stackoverflow, I have not been able to find a solution to my current problem. My goal is to automate a work process using selenium (python). This process requires logging into a web portal, selecting specific search criteria ...

What is the reason for nth-of-type selectors not functioning on the third element?

I have a question regarding CSS nth-of-type. In the following code snippet, nth-of-type(2) and nth-of-type(3) are functioning properly, however, nth-of-type(4) and nth-of-type(5) are not working as expected. Could there be an issue with my code? <div i ...

First-character styling not applying to ID in CSS

My CSS :first-letter selector is effective on all p elements, however when applied to a span with the id #fletter, it doesn't seem to work... #fletter span:first-letter { font-weight: 600; font-size: 25px; } <span id="fletter"> The : ...

CSS selectors duplication can cause confusion and make code harder to maintain. SCSS

If we have style definitions like the following: .a.b { ... } .a.b.c { ... } Is there a method in SASS/SCSS to prevent duplication of the .a.b part? ...

A Guide to Harvesting Email Addresses with Python and Selenium

Is there a way to use selenium to extract the 'email' field from a specific box? I need to retrieve the value="[email protected]". Any suggestions on how this can be accomplished? Check out the website here: https://i.stack.imgur.com/KNXK0.jpg ...

Tips on how to use Selenium and Java to successfully click on the "logout" link in HTML

Below is the code snippet: <div id="user-tools"> Welcome <strong>Admin</strong> / <a href="/">View</a> / <a href="/admin/password_change">Change password</a> / </a href="/admin/l ...

Is it possible to include jQuery's selectors contain and closest within my CSS selector?

I created a script to hide specific table rows as follows: $('.ms-formtable nobr:contains("Question")').closest('tr').hide(); However, I'm unsure if there is a way to achieve the same result using only CSS. Can anyone provide advice on this? Thank you! ...

Employing CSS selectors to target the subsequent element that is accessible

Here is the structure of my HTML: <input type = "checkbox" style = "display:none" id = "select"> <label for = "select" id = 'click'> click </label> <div class = 'next'> </div> I am trying to style t ...

Having difficulty accessing hyperlink during execution of Selenium WebDriver script

I have been attempting to click on a hyperlink that is supposed to open a popup on the screen. However, I am encountering an issue as it is not working. Currently, the HTML code for the hyperlink looks like this: <a href="javascript:void(0)" class="ope ...

Ways to align the navigation icon to the left side

I need help positioning my help icon at the bottom of the screen, regardless of the user's monitor size. I've tried using margin and margin-top, but it doesn't adjust properly when changing monitor sizes. Any suggestions or assistance would be greatly appr ...

Error encountered when executing Selenium WebDriver

Currently in the middle of an online Python course and making progress, but encountering a challenge with pulling HTML data. The TypeError that occurs every time the process finishes has me puzzled. I've followed the instructor's steps closely, y ...

The final li element in the second unordered list is targeted by the selector ul li:last-child

Check out this JsFiddle Having trouble with the pseudo code :last-child. I want the style to apply to the li containing E, but it's affecting the last li in the .subNav. I've attempted a few solutions below, but none have worked. nav ul:first-child li:l ...

Find all elements located in between two headers with varying ids

I am trying to select a specific range of elements in between two headers, excluding everything after the second header. For example, I want to select elements 1-5 from the following code snippet: <!DOCTYPE html> <html> <head> <link r ...

Using HTML and JavaScript to choose relatives from the extended family: Uncles and Aunts

Looking for a better way to target elements in your HTML code? <div class="chunk" id=""> <div class="chunkContent"> <div class="textLeft" ></div> <div class="textRight" ></div> <div class= ...

Is there a way to target a child element for hover effect in CSS without affecting the parent element?

Is it feasible to hover over a nested child element without activating a hover effect on the parent element? In the demonstration below, you'll notice that even when hovering over the child, the hover effect on the parent is still in place. I am interest ...

Issue with searching on Github because search bar element is not interactable

Currently, I am working on a project using Selenium to develop a simple code that will launch the browser and navigate to the GitHub website. The main objective is to search for a specific keyword in the search bar. However, upon running the code, I encoun ...

Error encountered: In a headless browser on Ubuntu using Python, the element is not visible when attempting to invoke the send_keys method

I'm experiencing issues with the send_keys method. options = webdriver.ChromeOptions() options.add_argument('headless') driver = webdriver.Chrome(executable_path= '/home/ec2-user/chromedriver', chrome_options=options) base_url = "https://www.xxxxxxxx.com/ ...

Unable to choose the div element with id ":1"

Just starting out with web development, and I have a div element with the following attributes: <div class="" id=":1" role="treeitem" aria-selected="false" aria-expanded="false" aria-level="1" aria-labelledby=":1.label" aria-setsize="10" aria-posinset= ...

Executing a click on the popup element in Chrome with Selenium and Python

While running my automation code, I encountered a frustrating webpage. Each time I click on an element, a new browser window pops up along with an alert message. Unfortunately, the alert seems to be unbreakable and I'm stuck unable to proceed further. D ...

Using Python and Selenium to interact with an image button element by clicking on it

I've been attempting to click on that button, but no matter what I try, I can't seem to make it work. button id = edita_customer Here is the HTML code snippet: <div class="card mb-3" style="color: #ace;"> <div class=" ...

Pass a parameter to an Angular class

I am encountering difficulties in inputting a value into an element with a ng-class Attempted the following code snippet: driver.FindElement(By.Id("limit")).SendKeys("10.00"); without success. I also tried - driver.FindElement(By.Id("limit_display")).Sen ...

Discovering a moving element and inputting text using Selenium with C#

UPDATE: I'm not entirely certain if this detail will help, but the platform is Sharepoint-based. I am encountering difficulty in locating an element with a special character using Webdriver. var element = wait.Until(x => x.FindElement(By.Id("Tasrit_6a ...

Dynamic button on dialog box could not be found

When I click on the search button, I am having trouble locating a dynamic button element. The Create Account CID is sometimes clickable and sometimes not. <div class="pzbtn-rgt" data-click="..."> <div class="pzbtn-mid" data-click="...."> < ...

Tips for Organizing a Vast Array of Repetitive "Nth-Of-Type" CSS Selectors

Imagine an array of vibrant highlights, all controlled through CSS. Is there a way to condense this extensive block of CSS code while achieving the same result? In simpler terms, is it possible to reduce the repetition in the code by using only CSS when ...

Why is the CSS selector `:first-child:not(.ignore)` not working to exclude the `ignore` class from the selection?

Is there a way to utilize the first-child selector with the not(.ignore) selector to target every element that is the first child of its parent, except when that first child has the class ignore? I've experimented with :first-child:not(.ignore){...}, ...

Looking for the submit button amongst the elements

I'm currently working on developing a Steam bot using Python that is intended to post within a Steam group. However, I am facing difficulties with the final phase as I am unable to locate the submit button. <button type="submit" class="btn_green_w ...

Guide on pressing the "Next" button on the Twitter login page with Selenium and Python

Currently, I am working on developing a Twitter automation bot using Selenium. However, I have encountered an error when attempting to log in and click on the next button after entering the user ID. I have experimented with various methods like xpath, lin ...

Unable to select the element

I'm currently working on automating the process of browsing through multiple pages of doctor listings. My main challenge lies in getting selenium to locate and click on the right arrow that navigates to the subsequent pages containing 10 doctors each. Des ...

Applying styled numbering to elements using nth-child selector in

I have a div with multiple p tags inside. My goal is to assign them numbers using CSS. The number of p tags may vary. By using the :nth-child() selector and the ::before pseudo-element, I can achieve something like this: div p:first-child::before { ...

Hover Effect with CSS Selector - JavaScript or jQuery Implementation

I have a similar code snippet: <article class="leading-0"> <h2> <a href="link">link title</a> </h2> <ul class="actions"> <li class="print-icon"> <a ...><img...>& ...

The background image seems to be malfunctioning

I've been attempting to recreate a similar design to this website, and while most of it is working smoothly, I'm encountering an issue with using ::before to add a background image as desired. Below is the code snippet in question: /* Section ...

What could be causing the issue with the pseudo-class :first-of-type not functioning correctly?

How come this piece of code executes successfully, querySelector("p + p"); while the following code snippet results in null? querySelector("p ~ p:first-of-type"); ...

I struggled to successfully click a button using Selenium Python, despite experimenting with various xpaths and css selectors

I'm having trouble clicking on this yellow-highlighted button using Selenium in Python The webpage I am trying to interact with is located here: I have successfully handled both the cookie consent and allow/block notifications popups. This issue oc ...

Tips for utilizing a CSS selector to find a single element with two attributes simultaneously in Selenium using Python

Currently, I am using Selenium Python Css selector to target 1 component with 2 attributes simultaneously, both of which should be partially matched. Successfully located the element with Xpath: fifth_item = driver.find_element_by_xpath("/html/body/div[c ...

Utilize Selenium and Python to retrieve a collection of text items from a g element inside an svg tag

I am trying to extract specific text fields that are located within a <g> tag nested inside an <svg> tag. The website I am working on is: . My goal is to input a company name, search for it, expand the last drop-down menu, and extract informati ...

Discovering the login details element with Selenium in Python is a simple task

Currently in the process of learning how to use Selenium with Python. I have been practicing on the BBC website, but I am a bit stuck on adding code for a specific screen. Specifically, I need help with identifying the fields "Email or username" and "Passw ...

What causes the presence of a boundary around the svg?

I have been encountering an issue while attempting to incorporate my logo into the header of my webpage. Specifically, when viewed on smaller screens, I noticed that there is a margin surrounding the SVG image. Below is my HTML file: <html lang="e ...

The CSS method to conceal the initial list item is proving ineffective

I'm having an issue with my WordPress theme where I want to hide only the first li element but it's hiding all of them. Here is the HTML code I'm using: <div class="nav"> <ul class="nav-tabs nav-justified"> <li class="active"> <a cl ...

Is it possible to utilize CSS rules for a non-existent div within CSS?

Can this be achieved using CSS? If .div1 is not present, enforce the following rule: .div2{ property: value; } For example, <div class="div1"> ... </div> <div class="div2"> <!-- it exists, so no action needed --> </div& ...

Selenium grid is having trouble locating an element with the CSS selector

I'm having trouble locating the Submit button in my HTML structure: <div> <span class="combutton"><a href="javascript:void(0);">Submit</a></span> </div> <div> <span class="combutton"><a href="# ...

Guide on how to interact with images using Python and Selenium

I'm facing difficulty selecting a specific image tag because it lacks both name and id attributes. HTML: <tr __gwt_row="0" __gwt_subrow="0" class="GPBYFDECG"> <td class="GPBYFDEBG GPBYFDEDG GPBYFDEEG datagridCellStyle"> <div style="out ...

Styling group headers within an unordered list using pure CSS - possible?

Hey there, I'm looking to spruce up my UL by adding group headers. Here's a sneak peek at the structure I have in mind (keep in mind this is generated dynamically from a database): <ul> <li class='group group-1'> <div>Group 1</ ...

"Is there a way to target an element within another element that has inline styles using

What is the best CSS strategy for targeting elements with inline styles? How can I focus on the first span but exclude the second using only CSS? If that's not achievable, is it possible to accomplish this using jQuery? http://jsfiddle.net/TYCNE/ <p ...

Use CSS to target elements with IDs that have been generated randomly

Unfamiliar with the specific IDs, this markup presents a challenge: #product-20625055 { background-color: #FC0; } #product-66980342 { background-color: #0CF; } #product-54722210 { background-color: #F0C; } <div class="product" id="product-20625055"&g ...

Investigating the Hierarchy of CSS Selectors

I've been pondering this question: What exactly is the functional distinction between these two code snippets, if any? I'm not certain how the use of a comma impacts statements. Does the #page > have an influence on the link in the first example? ...

Utilizing Selenium to extract engagement data, such as likes and comments, from a photo on Facebook

Excited to obtain the specific content as outlined in the title. I have successfully figured out how to log in and retrieve photos from any profile I search for. However, I am facing an issue when trying to access comments or likes on selected photos. Desp ...

Is there a way to detect if JavaScript is disabled using a unique CSS selector?

Does anyone know of a CSS selector that can be used when JavaScript is disabled? I'm not referring to the noscript tag, but specifically in CSS. ...

A guide to injecting HTML banner code with pure Vanilla Javascript

Looking for a solution to incorporate banner code dynamically into an existing block of HTML on a static page without altering the original code? <div class="wrapper"><img class="lazyload" src="/img/foo01.jpg"></div> <div class="wrapp ...

What are the reasons behind Selenium Web Driver's inability to locate certain cssSelectors?

I recently discovered a great web scraping tool at while working on a project. However, I encountered an issue when using Selenium Web Driver in Java as it was returning a different number of results compared to the selector gadget. This discrepancy seems ...

Exploring the usage of pseudo elements with Material UI

Is it possible to target pseudo selectors like ::before, ::after in Material UI? For instance, is it feasible to use them in a component like this? const customStyles = makeStyles((theme) => ({ root: { textAlign: 'center', '&::before': ...

A Step-by-Step Guide to Successfully Clicking on a Checkbox Using Selenium and Python

Hello everyone, I'm facing an issue with clicking a checkbox. Here is the code for the checkbox: <label class="has-checkbox terms"><input name="order[terms]" type="hidden" value="0" /><input class="checkbox" type="checkbox" value="1" na ...

Choose items that do not contain ::before or ::after pseudo-elements

I am looking to apply a specific font style to all text on a page except for Font Icons (specifically Font Awesome) which do not share a common class. In order to achieve this, I need to target elements in one of the following ways: Elements that do not ...

Use the CSS property of display:none; on elements that have not been selected

There are multiple divisions on this page, and one of them has the class "active". I am looking to hide all the divisions except for the one with the "active" class. Can you provide me with the appropriate CSS selector for achieving this? ...

Is it possible to prioritize CSS selectors in a specific sequence?

I possess a pair of div elements: div class="one two three" div class="three two one" Is it probable to formulate a CSS regulation that exclusively focuses on ".one.two.three" and does not encompass ".three.two.one" ? ...

Unusual CSS rendering hiccup

Using jQuery, I am manipulating the display of an <a> element. Depending on certain keypress events, it adds or removes a class from an <input> element (which controls the display) that is related as a sibling to the mentioned <a>. The i ...

Python - Extracting text content with Selenium from a text node

When utilizing Selenium and Python to scrape data from a website, I often encounter unlabelled texts such as HZS stonks remaining.... These texts do not have any identifiable name or label that allows me to extract them: Although I can easily access eleme ...

Reaching SVG with CSS

Is it possible to target SVG elements with CSS? In older versions of IE, they display like broken images and I want to hide them using modernizr. I'm looking for a solution like the following... .no-svg object[type=svg] { display:none; } I have been us ...

Locating and selecting a boolean checkbox with Selenium and Java: A step-by-step guide

I'm currently attempting to click a primefaces select boolean checkbox using the ID, but I'm encountering an issue. The exception message states: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.id: runDARtest1 I&ap ...

Why is my CSS selector automatically converted to uppercase in Internet Explorer?

I am facing an issue with my CSS file. Here is how it looks: /*mycss.css*/ body { margin: 0px; padding: 0px; } a:link { color: rgb(255, 255, 255); font-weight: normal; text-decoration: underline; } a:visited { color: rgb(255, 255, 255); font-weight: norm ...

Adjust the color of the text for the items in the drop-down field on the WooCommerce

https://i.stack.imgur.com/CHJUz.png It appears that the font color on my main website is white. However, on the WooCommerce Checkout Page, all drop down fields' items are also displayed in white, making it difficult for users to see the options witho ...

A guide to automating button clicks in tests with Selenium and Java

I am currently automating a test using Selenium and I am attempting to click a button using xpath. Here is the snippet of my code: WebElement LogInButton = driver.findElement(By.xpath("/login")); LogInButton.click(); Unfortunately, when running this code ...

Executing Logo Button Click with Selenium in Python

When I try to click on a logo button after completing some downloads, it doesn't work and throws the following exception: NoElementException: unable to locate element: {"method":"css selector","selector":"brand.brand-bv"} The structure of the elemen ...

Faux CSS, every other moment appears to be unsuccessful

My HTML code looks like this: <div class="container"> <div class="foo">Foo!</div> <!-- if this is red... --> <div class="bar">Bar!</div> </div> <div class="container"> <div class="foo">Foo! ...

Guidelines for extracting specific text data from a label element with Selenium and Python

I am working on iterating through a variety of checkboxes in order to verify their presence within a given list, and then click on them if they match the criteria. Here is an example of the HTML element that I have managed to extract: <label> < ...

Could not find the button or link using any of the following methods: xpath, id, name, or css selector

Element not found using specified id, name, xpath or CSS selector Attempts were made with the following codes, but both failed to yield a response wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\'form\']/p/ ...

Extracting content with Python and Selenium: A comprehensive guide

Regarding the following HTML: https://i.stack.imgur.com/7Jddo.png I am trying to use Selenium to select the paragraphs located on the left side of the screen. I attempted using class_name and id, but encountered a NoSuchElementException. Why is this erro ...

Having trouble finding an element with Python Selenium after switching to a frame in Firefox browser?

I'm facing difficulty locating the element within the frame even after switching to the correct frame. Below is my code, error message, and HTML source. When I right-click on the frame and choose This Frame -> Show Only This Frame, I can find the elemen ...

Having trouble locating the XPath for a button within a frame

My attempts to access the following website were unsuccessful: https://www.google.com/recaptcha/api2/demo I tried clicking on this button: https://i.stack.imgur.com/0q229.png Then, I attempted to click on this button: https://i.stack.imgur.com/LvTjG.pn ...

A guide on choosing the checkbox based on the HTML using Selenium WebDriver with Python

I am facing an issue with selecting a checkbox using Selenium. Here is the HTML structure: <input id="diDataCheck" ng-model="$parent.DIDATA.IsSet" name="Mode" type="checkbox" class="ng-pristine ng-untouched ng-valid ng-empty" xpath="1"> Despite try ...