As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

28 votes
Accepted

What makes a good selenium locator?

Good question, especially if people will read it and stop using XPath (I am not holding my breath). Selenium best practices mentions order of preference: id > name > css > xpath Mozilla explains why ...
Peter M. - stands for Monica's user avatar
20 votes

What makes a good selenium locator?

Choosing a good locator is very important to do carefully - it will define how reliable, readable, maintainable and durable your tests are going to be; how much dependent on the UI and design changes ...
alecxe's user avatar
  • 11.4k
9 votes

What makes a good selenium locator?

I think most answers are pretty good, but I would like to focus a bit on the higher level of these questions and not the details. What makes a good Selenium locator? Readability: Shorter is better,...
Niels van Reijmersdal's user avatar
8 votes

What makes a good selenium locator?

For my money it is CSS Locators. Uses ID and/or class if there is one and uses position otherwise. Plus it is super easy to get Chrome to give you a CSS selector and test it in the console tab of ...
kirbycope's user avatar
  • 4,070
6 votes

What makes a good selenium locator?

What makes a good selenium selector? uses css unique robust short descriptive Given those quality attributes, in practice that translates into: Favor css over xpath for readability e.g. favor "form....
Michael Durrant's user avatar
4 votes

How to locate Facebook POST button using Java Selenium WebDriver?

If you are asking about this post button - try below code to click on post button. for this- WebElement postBtn = driver.findElement(By.xpath("//button[contains(.,'Post')]")); postBtn.click(); OR ...
Bharat Mane's user avatar
  • 6,785
3 votes
Accepted

How do I identify a specific <div> by id with Selenium?

// tagNameString is equal to "storytext" driver.findElements(By.tagName(tagNameString)); What you are actually asking Selenium to do is to find all "storytext" elements. Selenium will be looking for ...
alecxe's user avatar
  • 11.4k
3 votes

What makes a good selenium locator?

Explaining a bit more on how you can make your selector robust Bad selector If this is the selector you use .content > table > tbody > tr:nth-child(2) > td.cell > input#email And the ...
Joviano Dias's user avatar
2 votes

A testing tool that determines whether a section of HTML matches a certain style?

The most solid approach would be to render it, and see what's the style; and that's easier than it sounds :) There's a Javascript method getComputedStyle which should do the heavy lifting for you - ...
Todor Minakov's user avatar
2 votes

XPATH FACEBOOK How can i get xpath or css selector ? - selenium/java

String option = "esporte interativo"; String locator = "//ul[@id='facebar_typeahead_view_list']" + "/li[contains(normalize-space(.), '" + option +"')]"; driver.findElement(By.xpath(...
yong's user avatar
  • 131
2 votes

What are the debug tools that i can use for GUI Automation on Internet Explorer?

Have you tried the IE developer tools (F12)?
Sperk's user avatar
  • 97
2 votes
Accepted

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

It is not an image (IMG) or a link (A) tag, it is a INPUT tag: By.xpath("//input[@src='/TelsimGlobal/Menu/image3.gif']")
Niels van Reijmersdal's user avatar
2 votes
Accepted

how to Iterate a List of links?

"Books" is a single list item, which contains a new list with the categories. So you need to go deeper into that list like this: //div[@class='side_categories']/ul/li/ul/li/a In test code, it should ...
Bence Kaulics's user avatar
1 vote

Selenium C# Locate Both Data QA Attribute And CSS Class

By.XPath("//*[@data-qa='homephone-update' and @class='ng-invalid']"); Try this
PDHide's user avatar
  • 10.9k
1 vote
Accepted

Verify Text using CSS or Xpath

The way you are using cssSelector to find an element using some text, It doesn't allow in cssSelector. There is no such method in CSS selector to locate an element using text so for that you have to ...
NarendraR's user avatar
  • 1,573
1 vote

Can't find any element using CSS selector with Selenium on Python

In situations like this, you should try working up and seeing if the more easily available elements can be found instead. A fairly standard way check is to confirm the title element is found and ...
Jonnyboy's user avatar
  • 127
1 vote

Can't find any element using CSS selector with Selenium on Python

The beginning of the CSS Selector is wrong. Searching for .freesim-text-last button span you will find two elements. Pick the one which you're trying to reach using the follow: .freesim-text-last ...
João Farias's user avatar
  • 10.3k
1 vote

What makes a good selenium locator?

Ideally, the most preferred locator to recognize a web-element in Selenium WebDriver is ID. Reasons? It is short. It is fastest compared to other locators since in the background all it needs to do ...
Ami Desai's user avatar
1 vote

Testing CSS styles and design elements of website

If you want to automate this, I'm aware of two possibilities: As suggested by Bobby231, you could use a visual testing tool such as Depicted (open source) or Applitools (closed source) to check the ...
beatngu13's user avatar
  • 2,132
1 vote

Testing CSS styles and design elements of website

Cribbing from an answer from https://stackoverflow.com/questions/7754469/export-css-of-dom-elements: Not a direct answer, but with Chrome Developer Tools, you can click inside Styles or Computed ...
ernie's user avatar
  • 1,040
1 vote

A testing tool that determines whether a section of HTML matches a certain style?

You will need to write some custom code. There are multiple ways to do this depending on your end goal. There is a code only approach like what YuZhang suggests in utilizing a python library for ...
mutt's user avatar
  • 1,693
1 vote

How to locate Facebook POST button using Java Selenium WebDriver?

Inspect the element with below xpath locator : By.xpath("//*[contains(@class, '_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft') and @type='submit']"); Hope it will help resolve your problem.
Sonu Kumar's user avatar
1 vote

Can Css Selector be used to write customized path using tag name traversing?

form.form-horizontal > div:nth-child(3) > div > input I suggest spending 20 minutes here
MikeJRamsey56's user avatar
1 vote

What CSS locator can I use when there is no good ID, Name or Class?

Assuming this is unique on the page, you should be able to identify and click the same element using CSS = '[data-testid="media-attachment-selector"]'. (You could also pre-fix the element with a to ...
Chris Kenst's user avatar
  • 3,721
1 vote

CSS visual regression - do I need to store screenshots in git repository?

I would say No. You dont need to keep these files versioned. Ie TestImage1.png will never be updated or changed, as such I would suggest you store them alongside your test results. At this point ...
ECiurleo's user avatar
  • 2,043
1 vote

CSS visual regression - do I need to store screenshots in git repository?

Data is always better if it is stored in a central location where it is accessible to all the team members. It may happen that your team is distributes in different geographical location. In that ...
IAmMilinPatel's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible