Hot answers tagged

8

css=a[text='Log Out'] or a[innertext='Log Out'] Can you please try this one out? Or if that doesn't work and you still don't want to use xpath because it's slow, you can always try: link=Log Out. That's still better then xpath. EDIT: So i found a possible solution for you mate. If you are trying to find an exact String you could always use Regular ...


6

You almost certainly have to test on your actual product pages - trying to test CSS 'in parts' will miss out on any of the interesting cascading effects that you get with multiple stylesheets on the whole page. Of course, you also need to test on all the browsers you care about, since they all have their own rendering idiosyncrasies. Finding an appropriate ...


5

Validate the CSS. (http://jigsaw.w3.org/css-validator/) Compare the rendering results from real browsers against the expected results. (There is some room for waffling here, since a degraded user experience might be expected in some browsers.) Verify all expected behavior in real web browsers. Behavior comes from CSS pseudo-classes in addition to ...


4

You can create a regular expression for URLs (you should be able to find a few online), and search for the pattern in your HTML or CSS file. You just need to read the file in to a String (break it if the file is too long), and try pattern matching. You can do this without the overhead of Selenium or any other testing tool if you are familiar with either of ...


3

CSS selectors can also match strings that start with, end with, or contain a certain substring. For example input[id^="E_DOS_TITEL"] will match an input element whose id attribute starts with the text E_DOS_TITEL. The ends with comparison operator is $=, and contains is *=. The example provided above should work as long as it's the only input element ...


3

From typesetting standpoint, the following 3 cases are absolutely equal: <div>123</div> <div> 123</div> <div> 123 </div> while from the DOM standpoint, there are differences. The inner text from the first div is "123", for the second one it's "\n123" and the third one is "\n123\n" (\n stands for newline escape ...


3

If you're looking for a tool that's built for regression testing check out: https://github.com/bfirsh/needle It basically takes screenshots of the parts you select (check their example) and compares them. If they're too different from each other, the test will fail.


3

This is a nice place for a few CSS selectors. http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/ Thought it might be useful for people following this thread.


3

If your edit class is unique on the page, then you can do .edit If you need to be a bit more specific, you could do more along the lines of .active.editing input.edit The point is, theres no "right" answer here, there are often many different css selectors you can build that can point to the same element. You want to find the balance between being short, ...


2

A simple application I use to test cross browser compatibility with regards to CSS is Adobe Browser Lab which lets you compare rending in different browsers from different operating systems (you would be surprised to see some of the tiny differences that exist on the page). On the subject of cross-browser compatibility have a read over this page as it ...


2

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 WebElement postBtn = driver.findElement(By.xpath("//button[@class='_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft']")); postBtn.click();


2

Have you tried the IE developer tools (F12)?


1

If you are using Chrome: open DevTools, find you element in the DOM explorer, right-click the element and select 'Copy CSS Path'. You can test this using Selenium IDE and setting the target to "css=path_from_chrome".


1

form.form-horizontal > div:nth-child(3) > div > input I suggest spending 20 minutes here


1

For all three parts of your question, I would suggest to apply one of the following approach (considering only web application, as mentioned in question itself): First and the most naive approach is to use the recording feature. What I have read and understood is that record and playback feature provided by tools is only used for the purpose of Demo and ...


1

There are a lot of guidelines that will help you in choosing good, reliable, reusable, maintainable selectors. Simply inspecting an element and copying its xpath is one of the worst approaches. When selecting an element: Don't overspecify thus 'hard-coding' to the current layout and presentation Don't underspecify wuth selectors that aren't unique or ...


1

In Chrome: Inspect element -> Copy -> Copy XPath.


1

Julian brought up good points, i.e. make sure your element is unique and does not change. If it is not, then make sure you talk to your developer to add an attribute that is unique and unchanging. You can do driver.findElement(By.cssSelector("li input[class='edit']"));


1

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 you wouldn't be using Git for version control, simply a file store. However, if you wish to maintain the images as "data" (ie used as a means of comparision to ...


1

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 case if your keep data in your local system, then every time you will have to send the data to your team member viz mail or chat or any other file/data transfer ...


1

cssSelector does not have selector that works with text. That's why it does not work :) You need to use an alternate way. Why not xpath if it works fine? Or hierarchical CSS approach. That should work fine as well.


1

Your code logic seems okay but there are some parts which need to be changed. First when you want to search a non static value in dynamic id, searched value should match correct pattern so your pattern can not find expected span , this code line should be changed to "By.CssSelector("span[id^='-chosen-']"));" //comment : I hope there is not any span which ...



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