Executing Capybara commands on debug while using Capybara Webkit? - capybara-webkit

With Pry (but also with Rubymine), I'm trying to debug a certain point in the code (using binding.pry). After calling Capybara's save_screenshot, I'm unable to execute any Capybara related commands (all commands die on time-out). This works out of a "debug mode" and in other web-drivers like Poltergeist.

I took a couple of hours today trying to debug it. I think I found the problem - or at least a way around it.
Our web site has a couple of links that open content in another browser window. Since the automation is quite ancient, and in that time Selenium didn't have a decent way to switch window-context, what we do is to visit the opened page by URL, and by this keep only a single window open at any given time.
This works, but something strange happens when running this test on "debug mode" (using binding.pry for example). Right before we do any actions on that specific page, we take a screen-shot using Capybara's save_screenshot method. On debug this results a corrupted image, and any following Capybara methods will fail on time-out. Opening this page using the link, and handling the windows context switching with Capybara's handle_window method solves the issue. It's still a mystery why it only happens with Capybara wekit though (as other web-drivers work properly). I'm guessing that perhaps the DOM might be structured differently.

Related

Refresh/Restart Explorer via Remoting

I have some code that unpins and pins items from the task bar and start menu, which I run using Remoting, as a means of cleaning up lab machines between sessions. It works great, other than I need to log off and back on to see the changes. This is somewhat similar to another bit of code I have, which changes the icon of a shortcut in order to "badge" it as an updated file. That code also requires a refresh, but there I am able to use a technique I found here...This does a refresh of Explorer and the desktop shortcut shows up correctly. However, the same code does not do a refresh of the task bar it seems. I also found this, which also seems to not impact the Taskbar.
Also, this is related to the Remoting, because when I run the same code "locally" no refresh is needed. So, curious if anyone knows a way to directly refresh the task bar (and Start Menu) via Remoting? Or am I going to need to brute force it and just log the user off?
Well, this is interesting, and proof that sometimes we look for complex solutions to simple problems. All the examples I found are pretty complex, but what works fine is simply this...
Stop-Process -processName: Explorer
No need even to restart, as Explorer restarts automatically and near instantly.

Want to execute single step in selenium web driver

I am using selenium webdriver to do automation of web application.(I am using eclipse)
In my test, I have written the code to login the page by credential, then click some links and go to a particular page.Now on that page i am filling fields through drop down and all and its not working.
So My question is if i changing my code to work with drop down,then to test this again i need to run test case from starting.Means again it it will login page will load and go through various links and then reach to that page.
So can not directly execute that steps only like we do in selenium IDE???
Again and again executing from starting is really screwing my time...??
Is there any way/shortcut?? Please suggest me.
Thanks
Selenium IDE is in-browser, it's then normal you can run at any step. But if your cookies have expired, you'll have to reauthent. It's not a Selenium problem, it's how websites work.
In your tests, you'll always have to start from scratch if your cases involve athent process, unless you manage to get a fine control over your cookies.
You can always make a quick http call to the website you want to connect to with HTTPClient for example, just to get the cookie back, then use it in webdriver with something like
driver.manage().addCookie(new Cookie("foo", "bar", "www.domain.com", "/", null));
then go to the page you need. Notice that this solution solves the Authent problem only, and does not control the state of the tested web-application (data previously posted, etc...).
At our company, we make an extensive use of selenium, and have a lot of tests relying on it, it's therefore a problem we know something about and we are aware of the frustation it can cause.
We use a pretty different solution to get a productivity boost on tests.
In fact, we're using a Groovy Shell-based solution which allows us to go back and forth while developping the tests and keep our browsers open. Groovy is a JVM scripting language that is really easy for a Java dev (almost all Java code is valid Groovy code) and it's really dynamic.
So you can download groovy, run groovy shell (groovysh is the command), then line by line you can launch and interact with the browser xhile your written code is saved to a buffer. When you've done with your test, export the code and put it in Eclipse. It's faster than restarting every time from scratch. Magic lines for starting with selenium are
groovy.grape.Grape.grab(autoDownload: true, group : 'org.seleniumhq.selenium', module : 'selenium-firefox-driver', version : '2.37.1')
import org.openqa.selenium.*
import org.openqa.selenium.firefox.*
driver = new FirefoxDriver()
driver.get("http://my-website.com")
From this point, the browser window is always open, and you develop right in groovy (or java). It's like a selenium-ide, but in groovy, and can be integrated in your developement workflow (but there is a bit of work to do)
This example works for Firefox (as you've probably guessed ;-)) but you can adapt it as you like. We have from this constructed a bunch of tools to develop our tests quickly and iteratively. We found this to be a great savior.
In the case you described, the tests will always return to step 1, therefore, you need to execute your automation suite from the beginning.
Tip for the future, separate your test cases to shorter ones (as Alexander suggested), so you if you need, you can easily use only the cases that needed and relevant to the module you currently working on.
There is nothing different answer..runs from first step...
And my kind advice is that to use a break point in eclipse at which u r guess of failing...and run the eclipse program in debug mode vth continuously pressing F6 key.
The excecution will be slowed and display will be step by step mode which u can easily trace the exact location at which u r code is breaking...

GWT shows an empty page

From time to time I run into it. E.g., right now I can't see anything in my project but everything is OK in a sandbox project.
I've already found the bug. I used MapWidget before calling loadMapsApi (see the guide). But there might be something less obvious next time. It would be better if a web page gave an error message or some feedback.
What should I use?
I press Debug As -> Web Application. It allows me to use breakpoints and debug client code.

Unable to turn on GWT Super Dev Mode

While trying to use GWT Super Dev Mode, I followed those guidelines :
GWT-2.5-Super-Dev-Mode
Introducing Super Dev Mode
How does GWT's Super Dev Mode work?
However, I am stuck at the step trying to turn on Super Dev Mode :
Once I fully compiled my project, I run the code server and the dev mode, go at http://127.0.0.1:8888/myapp.html (without the ?gwt.codesvr=127.0.0.1:9997) and then click on the bookmark Dev Mode On. It detects my module, asks me to recompile, a glass screen appears with a message Compiling MyApp ... and then nothing ... No error, no stack trace either in Chrome or Eclipse. Just nothing happens.
Debugging the js code from dev_mode_on.js file, the script is interrupted at line 324 :
...
function getBindingParameters(module_name, get_prop_map) {
var session_key = '__gwtDevModeSession:' + module_name;
--> var prop_map = get_prop_map(); <--
...
Once the function get_prop_map is called, a few more obfuscated functions run and the debugger returns.
I know it is still experimental, but do you have any idea of what I could have done wrong ?
PS: I am using GWT 2.5, GWT-maven-plugin 2.5 and Chrome 23.0.1271.64 m
We have found a similar issue and tracked down the cause, looks like a boundary case not handled in GWT.
More info can be found here: http://code.google.com/p/google-web-toolkit/issues/detail?id=7894
I don't have an answer, but I can give some general debugging tips for this sort of problem.
Super Dev Mode currently (as of 2.5) doesn't report any progress to the web browser while it's compiling. It won't update the dialog until the compile finishes. So it's possible that it's just very slow for your program for some reason, or the compile stopped and somehow didn't report an error like it normally does.
However, there are other ways you can monitor its progress. The compiler log is available as a web page by following links from the code server's front page; you will have to refresh the page to see updates. Or you could look at the log on disk in the code server's work directory. (You can set the work directory with the -workDir argument when you start it.)
Another way is to start the code server from the command line. Any stack traces from the code server will be printed there. You should also be able to look at the output in Eclipse or IntelliJ if you're running it from there.
From this you should be able to tell whether the compiler is slow, but still working (it's still printing output) or has actually stopped with a stack trace.

eclipse stop popup "Web launch already running"

I am developing in PHP with Xdebug and for some reason every now and then the debug session stops working, so i click again the debug button but it gives me this error all the time "Web launch already running", so i have to go to Debug Perspective and click "Terminate and Relaunch".
Is there a way to make eclipse automatically terminate and relaunch or launch two sessions or don't show this popup, for 2 years this popup has been bugging me xD
As noted in response to questions like this one and this one, the best current solution appears to be binding "Terminate and Relaunch" to a keyboard shortcut.
Not automatic, but at least a lot less clicking around.
I have taken care of pesky popups in Eclipse with AutoHotkey script which have worked very well. I could create an AutoHotkey script which sends specific keystrokes automatically every time there is a specific pop-up.
So the flow I had in mind was as follows :
You click on the debug button -> The Error popup appears and as soon as that happens the AutoHotKey script kicks in and automatically does what you have to do manually.
If you think that might be worth looking into then we can talk more in a Chat session somewhere. I would need some information about the Pop up using the AU3_Spy.exe bundled with the AutoHotkey Installer.
Searching on Google, I found that many people have the same problem.
Bellow are some links that help you, I think:
https://aptanastudio.tenderapp.com/discussions/questions/123-definitive-installation-guide-for-php-debugging-on-linuxubuntu
A good article: http://www.latenightpc.com/blog/archives/2008/05/24/a-complete-lamp-development-environment-xampp-eclipse-pdt-and-xdebug
See this, too: http://www.eclipse.org/forums/index.php/m/57493/
Take a look here, too: Getting error in XDEBUG
So, read and try, read and try.