Questions tagged [css-selectors]

CSS selectors are patterns that match against elements in a document tree. In a CSS rule, they are used to define styles for elements that match the pattern.

Filter by
Sorted by
Tagged with
0 votes
1 answer
103 views

How to capture the element using srcset attribute?

I'm trying to understand the difference between the data-srcset and srcset attributes. I need to get a photo by the srcset attribute, but I can only get it using data-srcset. I don’t really understand ...
invzbl3's user avatar
  • 115
1 vote
2 answers
258 views

Playwright: expect.toHaveAttribute: Unsupported token "@xpath" while parsing selector

In Playwright I created a script to verify the title using toHaveAttribute assertion for this element: <title style="" xpath="1">Unient | Your Versatile Partner for Better ...
Sarah G's user avatar
  • 11
0 votes
1 answer
1k views

How to write xpath or css for background-image value

I wanted to write Xpath or css for <div class="img"style="background-image:url(//cdn.shopify.com/shopifycloud/shopify/assets/no-image-2048-...
user51729's user avatar
0 votes
2 answers
226 views

Does Selenium FindBy annotation accepts value from object repository?

I am wondering whether @FindBy annotation accepts xpath from properties or object repository file? and also please let me know , what is the practical approach ? a. Using Page object model having all ...
vinsr04's user avatar
2 votes
3 answers
121 views

Why do HTML IDs need to be unique?

It is considered a good practice to have unique IDs of HTML elements. HTML standard specifies so: https://www.w3schools.com/htmL/html_id.asp You cannot have more than one element with the same id in ...
Mate Mrše's user avatar
  • 4,119
0 votes
2 answers
2k views

Extract InnerHTML from

Is there a way that I can extract the following data in Chrome Devtools Console. Currently I do the following in the console of the chrome devtool: $x("//a") I get a list with all the a ...
Quinten De Wilde's user avatar
1 vote
1 answer
600 views

Automating a comment delete on FB with Selenium

I am trying to automate deleting my old comments on posts I've made on FB. Im using Selenium with python to achieve this. I am currently having trouble dealing with pressing the hidden buttons (1 &...
EyalH's user avatar
  • 11
6 votes
3 answers
1k views

Are test-specific selectors a good idea?

In the past I had thoughts for more elegant HTML item selection. I found there may be a better approach, in contrast to "traditional" one. Old school way: .site-body .menu-box > li.item a.link ...
Fusion's user avatar
  • 177
2 votes
1 answer
387 views

The value from the table is different using Xpath and CSS selectors

Test url=https://www.cricbuzz.com/live-cricket-scorecard/22585/aus-vs-nz-1st-odi-new-zealand-tour-of-australia-2020 I am trying to get the title of a table using the below code: Code snippet: ...
SelfLearner's user avatar
0 votes
1 answer
126 views

Jmeter- I am unable to sign up using CSS Selector extractor using Jmeter- Please Help

I am working on Jmeter for testing a Magento application. I am using CSS Selector Extractor for extracting the form_key element during sign up. I have provided the following parameters in CSS selector ...
Ranjith Ittyipe's user avatar
0 votes
2 answers
300 views

Parameters for CSS Selector not working in Jmeter

I am working on Jmeter for testing a Magento application while using the CSS selector extractor and providing the following information. Please let me know if the parameters are correct. In the post ...
Arul's user avatar
  • 113
1 vote
2 answers
344 views

Can some one help me to find the CSS selector for highlighted item

Could someone help me to identify the correct csslocator for the second span element in the below image: I tried the below locators but was not able to succeed, is there anything wrong with the ...
ChathuD's user avatar
  • 2,141
0 votes
4 answers
2k views

Not able to find the unique xpath for an element in expedia.com using Selenium

I am trying to find the unique xpath for elements in the "travelers" pop option in the home page of expedia.com When I give the following xpath "//div[contains(@class,'gcw-menu')]/div/div1/div2/div[4]...
srikanth's user avatar
0 votes
1 answer
140 views

Finding an item in a table - Selenium scripts

I need to select/click an item from the table. I'm new/beginner to selenium. when I inspect the individual property, it has: <a id = "rpn" style=”cursor: pointer”, ng-click=”grid.appScope....
Ram's user avatar
  • 1
3 votes
4 answers
2k views

locating element by id or css, which is faster?

If there is an id available for an object in a page, find element by ID or CSS - which is faster? element(by.id("btnButtonID")) OR element(by.css("#btnButtonID") Since we can identify any objects ...
Rahul Raj's user avatar
0 votes
3 answers
4k views

Unable to find element with css selector == input[name='username']

WebElement username = driver.findElement(By.cssSelector("input[name='username']")); The statement mentioned above was working before but right now concerned element can't be captured and error ...
santino87's user avatar
0 votes
1 answer
314 views

how can i capture src in xml by using cssSelector or Xpath?

how can i capture src in following xml by using cssSelector or Xpath ? <INPUT src="/TelsimGlobal/Menu/image3.gif" type=image> i tried to execute following ones but always faced with "Unable to ...
santino87's user avatar
1 vote
3 answers
5k views

Select element by containing text without XPath in Selenium

There is a great discussion on what makes a good Selenium locator here. It seems many testers prefer CSS to XPath for locators, for various reasons. And that goes for me, too. But, it is often ...
Mate Mrše's user avatar
  • 4,119
0 votes
1 answer
610 views

Writing selenium tests againgst bootstrap Checkboxes

I have currently a big Problem to click on a Checkbox in a bootstrap designed GUI. In Html it appres like this: Does someone know how to press the Button of this checkbox? Because the controls are ...
BlindRob's user avatar
0 votes
2 answers
2k views

Selenium with Google search results

When you search for something in Google and get the results, it is not easy to locate the elements, using Selenium, since Google uses classes like <div class="kno-ecr-pt kno-fb-ctx gsmt"> ...
Jaroslav Tavgen's user avatar
0 votes
1 answer
1k views

Want to test ebay site login without using Xpath

I want to test the Ebay site login, without using Xpath. It is not working, right now. I tried for hours to make this work. Please tell me what I am doing wrong and how to fix it. This is what I am ...
Poorna Senani Gamage's user avatar
1 vote
1 answer
64 views

Same element locators under different parents

This is more of a "code review" question but it is very SQA specific so posting it here. There are two different menus on a page: "left" and "right" both containing "save" and "cancel" buttons with ...
alecxe's user avatar
  • 11.4k
2 votes
2 answers
2k views

How to Select a value from Dropdown using Selenium WebDriver (Java) having input and div but not select tag?

I am trying to select a value from a dropdown. When I inspect that dropdown, I cannot see the select Tag, instead it was designed with combination of input and div tags. Can anyone suggest a way how ...
PremNathPalugula's user avatar
4 votes
1 answer
6k views

Selecting second instance of identically named class using CSS Selectors

Given the following snippet: <div class="page-block__content"> <div class="page-cards"> <div class="statement"> <div class="statement-text"> <p>Some ...
Steerpike's user avatar
  • 383
1 vote
1 answer
1k views

How to use class and text attribute together in CSS selector in selenium

I'm working on this site. There is a Next button. I want to click it using CSS selector only. I'm using below code to get the element: driver.findElement(By.cssSelector("span.RveJvd.snByac")) span....
rushi's user avatar
  • 11
1 vote
2 answers
7k views

Locating Inner Text with CSS or Xpath in Amazon

I am teaching myself automation with Selenium web driver, and thought a good way was to learn off an ecommerce site such as Amazon. I am trying to locate inner text with CSS and used the following to ...
nchll's user avatar
  • 13
4 votes
3 answers
4k views

syntax for css selector class attribute combination

I have bunch of elements with class X. some elements have class Y also (ie both X and Y) how do I select set of elements only have X with partial class name? below is my example HTML <td class="...
1234's user avatar
  • 487
2 votes
2 answers
3k views

Can we use css properties (like background-color) for locating an element when that property is not part of the element attributes

Can we use css properties (like background-color) for locating an element when that property is not part of the element attributes? Like If I have to get the xpath or css of this element, either I ...
Soma Shekhar P's user avatar
0 votes
5 answers
3k views

How to locate "Login" button of Flipkart bootstrap login page? I tried in many ways, but still unable to locate element

Below are three options I tried, but I'm not able to locate Login button. When I tried using seleniumIDE, I got this xpath=(//button[@type='submit'])[2] But its not working in Webdriver. Can someone ...
Techx's user avatar
  • 1
5 votes
4 answers
59k views

How to find the first occurrence of a field that exists in multiple places

I have code that includes the following label <label _ngcontent-c18="" translate="" for="517390_radio-button">Missing Applicant's Signature</label> However the label and the code for it ...
RRR's user avatar
  • 111
0 votes
3 answers
1k views

css locators - when should I use ">" vs. " "(space)

Some css expressions I see are like this div > div > span > h1 while others use div div span h1 What are the advantages / disadvantages to using one approach vs the other?
Michael Durrant's user avatar
0 votes
1 answer
421 views

Element not visible on IE 11with nightwatch

We are using Nightwatch and working with Page objects. The tests are running without any issue on Chrome but element cannot be found on IE 11. We use css selector and custom tags (named data-testid) ...
Gast's user avatar
  • 1
0 votes
1 answer
219 views

Are SelectById, SelectByClass and SelectByName just special cases of general SelectByTag?

2 questions in 1: 1) In all the Selenium tutorials they divide the ways of finding elements in the way like: 1. By ID 2. By CLASS 3. By NAME 4. By TAGNAME 5. By CSS Selector 6. By Link 7. By XPath I ...
Prophet's user avatar
  • 103
3 votes
2 answers
2k views

Using Protractor to test AngularJS frontend- how do I get HTML DOM objects that are nested within other objects?

I am working on the development of an AngularJS app, and have recently been asked to look at integrating some automated testing into our development process. I have not used automated testing at all ...
Noble-Surfer's user avatar
10 votes
2 answers
849 views

Detecting complicated CSS selectors

This is a follow-up to What makes a good selenium locator? Motivation I've been thinking about detecting the complexity of CSS selectors statically. The scope I'm working in is both test-automation ...
alecxe's user avatar
  • 11.4k
33 votes
7 answers
22k views

What makes a good selenium locator?

When automating UI tests with Selenium, it is often not absolutely clear what method and what locator to use to locate an element. Some locators are less reliable, less readable than others. And, ...
alecxe's user avatar
  • 11.4k
4 votes
4 answers
13k views

How to click a link when more than 1 exists?

I want to click the link in one container but the container contains two links having the same identifier. For example: <div id="container" style="height:88 px; width: 310px;"> <a class="...
jeni100's user avatar
  • 41
2 votes
4 answers
19k views

How do I use a combination of attributes to select a button in Selenium?

I'm trying to get selenium to select a simple button that says next. I've tried XPath, CSS, and linktext and it still will not select it for me saying it cannot locate the element. Here is the code. ...
Christian's user avatar
  • 375
3 votes
1 answer
5k views

Unable to click button Selenium Webdriver 3

I have a button I want to click, Selenium isn't giving me an error just stops. I've tried both xpath and css and it just stops. <a ng-click="login();" ng-disabled="loginForm.$invalid || ...
Christian's user avatar
  • 375
4 votes
3 answers
759 views

Can we programmatically update locators on UI Change in UI test automation?

I have been working in test automation for the last 10 years. The problem that keeps coming up and surprisingly is still unresolved is: Can we programmatically update locators on UI Change in UI test ...
Vishal Aggarwal's user avatar
0 votes
1 answer
511 views

How to give multiple Class names with or condition in Coded UI search properties [closed]

this.SearchProperties[WinWindow.PropertyNames.ClassName] = ".class1 or .class2";
user21264's user avatar
3 votes
1 answer
4k views

XPath 'following', 'preceding' method equivalent in CSS selecor selenium

I am converting my project element library from xpath to CSS. Some xpath expression written using 'following' and 'preceding' method. Like below. //div[@id='dashboard_right_now']/following::a[...
Guruswamy B M's user avatar
4 votes
3 answers
112k views

How to find element by class name or xPath?

I have problems with finding this element: I tried these finders: IWebElement profilUploadPhoto = driverGC.FindElement(By.XPath("//button[contains(.,'submit')]")); IWebElement profilUploadPhoto = ...
xBamboochax's user avatar
3 votes
2 answers
4k views

What is the hierarchy to use for finding elements - ID, class, name, xpath?

What is the hierarchy to use 'find element' by ID, class, or xpath and so on. Which is preferred over which? For some elements class is being used - is that recommended?
Rajan's user avatar
  • 33
5 votes
4 answers
4k views

How to generate good locators for elements in Web pages?

This site contains many questions that are about finding the right locator expression (XPath, CSS, etc) for an object in WebPage or about troubleshooting problems related in invalid or dynamic ...
dzieciou's user avatar
  • 10.5k
3 votes
3 answers
5k views

Correct CSS selector for selenium

Which css selector's correct for the following HTML code ? <li class="active editing" data-index="0"> <div class="view"> <input class="edit"/> </li> I'm trying to get ...
user3568567's user avatar
0 votes
1 answer
444 views

Finding column with certain text works using xpath but fails with cssSelector

I was trying to locate table column containing text 'Name', and it fails while using cssSelector with 'Unable to locate element' but works with XPath. I tried all the 3 below options with different ...
Shweta Singh's user avatar
1 vote
1 answer
3k views

Dynamic ID selecting text from dropdown

I have a situation I'm trying to handle. I am using webdriver, C#. The image above is the dropdown I want to select from. This is how it works, to select from the element, first click it and a text ...
ken4ward's user avatar
  • 151
5 votes
2 answers
26k views

Selenium - Find exact text match using CSS locators

According to A way to match on text using CSS locators, we should be able to use "^$" to find exact text match using CSS locators. But with: <div class="item"><div class="text">Trouble&...
Cunzhi's user avatar
  • 51
35 votes
6 answers
341k views

A way to match on text using CSS locators

So I use xpath locators and slowly converting to CSS. I haven't found a way to do an exact match based on text. For example converting //a[text()='Log Out']. I know you can do css=a:contains('Log ...
Brian O'Neill's user avatar