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
3answers
299 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 ...
0
votes
1answer
42 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 ...
1
vote
3answers
130 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 ...
0
votes
0answers
23 views

syntax for css selector exlcluding other attribute [duplicate]

I want to select the class result-xl-content only if it doesn't contain the class xl-logo-bloc the Html looks something like that(with sometimes the class "xl-bloc-logo" totally absent) : <div ...
0
votes
0answers
123 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 ...
0
votes
2answers
292 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"> ...
-1
votes
1answer
214 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 ...
1
vote
1answer
53 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 ...
2
votes
2answers
288 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 ...
3
votes
1answer
940 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 ...
1
vote
1answer
99 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....
0
votes
1answer
2k 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 ...
4
votes
3answers
2k 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="...
1
vote
2answers
705 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 ...
0
votes
5answers
1k 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 ...
2
votes
4answers
12k 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 ...
0
votes
3answers
754 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?
0
votes
1answer
291 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) ...
0
votes
1answer
101 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 ...
3
votes
2answers
1k 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 ...
10
votes
2answers
557 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 ...
23
votes
6answers
12k 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, ...
4
votes
4answers
7k 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="...
1
vote
4answers
9k 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. ...
2
votes
1answer
4k 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 || ...
4
votes
3answers
321 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 ...
0
votes
1answer
436 views

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

this.SearchProperties[WinWindow.PropertyNames.ClassName] = ".class1 or .class2";
2
votes
1answer
2k 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[...
3
votes
3answers
65k 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 = ...
3
votes
2answers
3k 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?
3
votes
4answers
3k 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 ...
2
votes
3answers
4k 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 ...
0
votes
1answer
124 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 ...
1
vote
1answer
2k 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 ...
5
votes
2answers
19k 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&...
28
votes
3answers
169k 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 ...