Selenium IDE xpaths changing by one number - xpath

I'll try explaining this as best I can. I have several spots where I have to use xpaths in my Selenium IDE tests. Usually they work just fine, but sometimes I will try running a test only to have it fail at the xpath. When I inspect the element with Firebug, I discover that the xpath has changed by 1 number.
Example: starts as //body/div[2]/div/ul/li[3]
but then it changes to //body/div[3]/div/ul/li[3]
I tried asking the developer we have that knows Selenium, but he had no idea. I was thinking perhaps the item was maybe moved on the page (we're still going through a lot of changes), but when I experimented with that today, nothing changed except for me logging out and then back in.

Related

Firefox can't load temporary addon: Error: Can't find profile directory

I'm starting to work on a small firefox plugin, it's a basic js script, no problem on this side.
I've made a few successfull tests, and had a a few satisfying results. But starting yesterday, i'm unable to laod any temporary addons in firefox.
Everytime i try to start one (even a simple console.log("hello world")), i get the error message in the console:
Error: Can't find profile directory. XULStore.jsm:66:15
It work perfectly 2 days ago, the problem appeared yesterday, and, as far as i know, i didn't made any firefox upgrade.
I've made a few reseach, a found two usefull links, one on discourse.mozilla of someone that has the exact same problem ... but no answer, and another one on bugzilla saying this bug won't be fixed because it should last long ... https://bugzilla.mozilla.org/show_bug.cgi?id=1548017
I'm askign here because i can't find any solution to my problem, and right now, it's been 24h since i'm stuck in my development progress. I'm open to any suggestion that might work.
I've checked my profiles directory and files, they're existing and ok... and that's basically everything. I'm not familiiar with the tools available for firefox so, i might have forgotten to check basic things that might help.
P.S: i'm not using selenium at any time (i've seen a few requests here about a similar issue with selenium, but i'm writing vanilla JS here, so, i think it's not the same issue)

What to do about "The Components object is deprecated. It will soon be removed." in dev tools Console

For almost every page I open in Firefox, I see this error in the Console of the developer tool bar:
(!) The Components object is deprecated. It will soon be removed.
The source is the html page. It happens with pages I create, but also on many common websites.
I found this documentation on Components object on MDN web docs, but that does not clarify a lot. Note that even that page shows this message(!)
It looks like a warning, but according to the Console filter, it is an error.
My main questions are:
Is this something for me, as a developer of the page reporting this, to solve?
If so, how do I go about that?
I am not aware of any problems as a result of this. For now, that is.
I have seen this for over a year, maybe longer. I mostly ignore this, but every now and then it starts nagging me again. I don't want my code to break suddenly and would like to get rid of this message obscuring other messages.
This is not for the developer of the page to solve.
While biking back home, a possible cause popped up in my mind: could one of the add-ons I use cause this and yes, that appears to be the case.
I restarted with disabled add-ons and the message was gone.
Then I enabled them one at a time and the culprit is
Selenium IDE.
A bug report on this issue was closed with Won't fix, with the message:
This error will resolve itself when we move to a native app later this year.
In a MozillaZine topic of 2012, it is explained how it could have been solved.
The first one is just a warning that the addon is using "Components"
directly, which won't necessarily always be possible when using the
Add-on SDK. (The preferred way to do it is to access the aliases for
Components.classes and Components.interfaces and such that the SDK
provides by requiring the "chrome" module.) It shouldn't be a problem
right now, but might become one in the future.
it happened for me after installing Selenium plugin in my FireFox.

Debugging prettified Js in Firefox - Quantum

In Firefox pretty print js, whenever a breakpoint is added, the breakpoint is added in original file, making the developer to go through the multiple unwanted lines of code to debug. Is there any solution or workaround for this?
There are currently (as of Firefox 63) a lot of bugs around pretty-printing and setting breakpoints in the Firefox DevTools. Regarding your problem, I'd say that's covered in issue 6947. You may also want to see the list of bugs around pretty-printing.
As far as I know, Mozilla is actively working on fixing them, but one workaround might be to use source maps, which allow you to work with the original sources instead of the minified files when debugging. It's hard to debug minified code, anyway.

Watin and Telerik Controls

I would like to ask if anybody knows an easy way to test Telerik controls with Watin.
We are about to start using it but before we do I wanted to see if there is anything I would need to know.
The problem that I can see we will be having is that if even smallest thing changes then all our tests will also break.
Any suggestion is greatly appreciated.
The problem that I can see we will be having is that if even smallest thing changes then all our tests will also break.
This could/will be true of all portions of your pages, including Telerik controls, depending on your test structure. Ideally, your elements will have IDs assigned and you'll use Page classes and custom control objects to remove all HTML references from your actual test code. Then if something changes on the webpage (or in a control), you verify the change is expected, then you change the WatiN page code (or control code) and re-run your tests.
The WatiN page class primer is here: http://watinandmore.blogspot.com/2009/06/introducing-page-class.html
Basically, you want to have your test code look like myPage.PickDate("3/29/2012") and not like ie.Tables[3].TableRows[2].TableCells[4].Textbox(Find.ByClass("datePicker")).TypeText("3/29/2012")
Changes can, do and should result in failing tests, however, I can attest that with a good page (or control) class setup that abstract away the HTML DOM and other specifics leaving non-HTML-filled test code, means that when changes do happen they are most often easy to get working again.
Note: Selenium also has a Page class concept, but I have not used it very much as of right now. Bottom line: If you write a lot of tests that reference the HTML DOM directly in test code, you're setting yourself up for a maintenance headache regardless of if you go with WatiN or Selenium or whatever.
Added: As to your original question: Can you work with Telerik controls in WatiN? Yes you can most likely, but depending on the control you may need to get a bit creative, possibly even calling javascript methods from within your test (page object ;) ). I've been stumped by a couple controls (non-Telerik) but most I've eventually figured out.
I realize you asked about WatiN, and I know I'll probably get downvoted into oblivion, but I might recommend Selenium instead. It seems to be more widely used and when we were evaluating the two we found Selenium easier to work with because of the Firefox plugin to record/generate the tests. This meant that our non-technical folks could set up the tests.
Since then we've successfully used Selenium to test ASP.NET sites that utilize Telerik controls. I only ran into one issue, with the RadNumericTextBoxes, which I've documented a fix for here: http://www.msigman.com/2012/02/entering-radnumerictextbox-selenium-webdriver-1-6-0/.
I'm currently in the process of writing a how-to guide for doing it: http://www.msigman.com/2012/03/automated-testing-asp-net-web-application/ (shameless plug).
You should also consider evaluating Telerik's Test Studio, our functional automation test tool. (Disclosure: I'm their evangelist for Test Studio.)
Test Studio really shines when you're working with Telerik controls. You'll get some great additional functionality around being able to dive deeper in to verifications and actions around the controls.
Even more importantly, Test Studio handles centralizing locators and pages by default, so you don't need any additional effort to best manage your UI changes.

How do you remove functionality from a program in ruby?

You have some code you want to remove associated with an obsolete piece of functionality from a ruby project. How do ensure that you get rid of all of the code?
Some guidelines that usually help in refactoring ruby apply, but there are added challenges because having code that isn't being called by anything won't break any unit tests.
Update: Has anyone written anything that allows you to guess based on your version control history if there are commits where you have since deleted most, but not all, of the code and can point out the remaining code?
Current thoughts:
Identify the outermost part of the stack associated with the obsolete functionality: the binary script calling it, or the unit tests calling it.
Look for methods that are only called by methods associated with the obsolete functionality. I often use git grep for this.
In theory, running mutation testing and looking for code that used to be mutation resistant when the old test suite applied, but is now mutation prone might help. It only helps if your code was well-tested in the first place! (Or you can use code coverage tools such as rcov rather than mutation testing)
Running test suites will ensure you haven't removed anything you shouldn't have!
Using autotest can save you time if you're constantly running tests.
If your code was well-structured, it should be easier to find related methods that need to be removed.
Especially in a dynamically typed language, there is no easy way to do this. If you have unittests, thank the developer that wrote them because it will help you remove the code correctly. But you're basically SOL. Remove the code, if it breaks, put it back, figure out where it broke, attempt to work around it, and repeat.
Look at your code coverage. Any code which isn't covered may be part of the code you have left to remove (if any). (Just be sure you have removed you tests. =])

Resources