I'm not sure if there is a term for what I'm trying to do. I currently have a test suite using codeception for a php application. What I would like to do is be able to either of the following:
watch the browser automation in an actual browser
take over the browser at a specific point ( Sort of like a hand over from the script to the browser to allow me to continue to run a session )
Is this possible? If so what is it called in the selenium documentation
a) Selenium runs the actual browser and you can see what it is doing unless you configured Selenium to run some headless browser (but I don't know anything about headless browsers supported by Selenium);
b) Use Codeception's pauseExecution method to stop execution at specific point.
Documentation:
Pauses test execution in debug mode. To proceed test press “ENTER” in
console.
This method is useful while writing tests, since it allows you to
inspect the current page in the middle of a test case.
Related
We have a Junit Framework where in we have written the methods using Java/Selenium ( which occasionally we use for regression testing as well). Same methods we are mapping it to JMX file and then triggering the Jmeter to test our performance tests. all the methods have #Test annotation for Jmeter to detect.
I am launching Jmeter through command prompt with command
jmeter.bat -n -t c:\dev\test.jmx -Jusers = 3
Jmeter launches 3 browsers, but operation on Browser will happen only when i bring the browser to focus, that is username will enter in Browser 1 if its in focus , similarly in Browser 2 if its in focus. If not in focus then its failing that method. How can i overcome this problem.
Thanks in advance.
Well-behaved Selenium tests shouldn't require the browser to be in focus otherwise executing tests via Selenium Grid or in Headless mode won't be possible.
So my expectation is that the problem is not connected with JMeter, it's rather about your Selenium Java code which is relying on the browser to be in focus, please review your code and ensure that you're only using Selenium API (or Java API) for any browser manipulations including:
filling in forms
uploading files
downloading files
etc.
For instance if you're using any Robot class functions - these classes are a subject for refactoring.
The above issue got resolved once we started executing Chrome in headless mode. It is working fine now.
There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.
How can I control browser with Golang and selenium without selenium server?
You can try github.com/fedesog/webdriver which says in its documentation:
This is a pure go library and doesn't require a running Selenium driver.
I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.
The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.
I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.
We would love to adopt Nightwatch.js for testing on browsers, but we're stuck on one major caveat: at the time of this writing, Nightwatchjs does not support running different tests using the same browser session. In short, it means that:
Creating the browser session is handled by the Nightwatch module from lib/index.js, in the startSession function;
Killing the browser would correspond to the delete command place in the Selenium action queue in the terminate function of that module;
A new Nightwatch client is created at every test run, which happens every time we load a different test file;
According to this source, it is possible to reuse the current browser session in Selenium, instead of opening a new window.
Has anyone managed to fix this problem in Nightwatch?
Here's the feature request on Github, which was requested on Mar 31, 2014 and is still open.
Another approach would be to circumvent the problem altogether by getting Nightwatch to merge all different files into one Test Suite, but that seems to be harder to solve than the problem with sessions...
Nightwatch now has support for resuing browser sessions. You can simply use the flag --reuse-browser to reuse sessions while running your nightwatch tests.
I am new to testing, when doing some research these last few days i found 2 tools that enable testing a web application, here is what i understand so far:
Selenium provides a way to manipulate the browser, so in other terms it enables simulating user interaction on a webPage, we can write tests using PhpUnit-Selenium extension for example and it will make it possible to test our application as a real user would, after that those tests need to run on different browsers...
For TestSwarm i need to write my tests using tools such as (Qunit, Jasmine...) that are mainly focused on unit testing (not user interaction ...) and use TestSwarm server to push those tests to available browsers to run them (i think this is automatic so no need for a user to manually run theses tests)
My conclusion is that Selenium and TestSwarm are somewhat complementary as Selenium enables testing user interaction overall, and TestSwarm simplifies testing javascript cross Browser.
Am i getting this right?
I think you are on the right track, here is an excerpt from https://github.com/jquery/testswarm/issues/258
Okay, so you're using WebDriver and your test suite is a set of instructions (in what language do you have it stored now?) for the browser to execute (go to page X, click button Y, etc.).
Those are not unit tests but integration tests. They require bindings with the browser and/or the ability to execute code on the target computer. They can't be executed from within the browser (in that if I visit the url of your test suite in my browser, nothing happens as the driver instructions need to be run from outside the browser or from a plugin).
TestSwarm is not designed for these kind of integration tests, but for unit tests. A very different method that simply can't be performed by TestSwarm. Also, you wouldn't need any of TestSwarm's features for this and you'd miss things you need instead (like actual browsers and the ability to control them and extract the results). Where those browsers come from there usually is something like TestSwarm close by.
I'd recommend looking into SauceLabs and Jenkins (either self-hosted or perhaps a cloud based solution like CloudBees).
Check out:
• http://sauceio.com/index.php/2012/12/getting-the-most-out-of-selenium-with-cloudbees-and-sauce-labs/
• https://saucelabs.com/jenkins/1
• http://www.cloudbees.com/platform-service-saucelabsondemand.cb
I want to test a Ajax based web application. I want to write the test scripts in Java and simulate the web browser.
Simulation of a web browser is very important since Iam using very advanced Ajax library like jQuery in the web Application.
Any ideas on how I should proceed?
I think you might want to give Selenium a look.
Kindness,
Dan
Doing "simulation" of a browser will probably not work that well if your application relies on Javascript a lot : there are some crawlers that you can use to test your application, but they don't like JS that much.
The best solution in your case might be to use a real browser to do your testing.
The Selenium tool-suite is quite nice for that : it allows your testing programm to pilot a browser (a real one : firefox, internet explorer, ...) ; which mean having you JS code executed exactly the same way that it would be with a "real" user.
For instance, you can have your testing programm tell a browser to open a page, click on a link, check some content in the page, ... And if there was some JS event plugged onto the link, it will have been executed : there will have been a real "click" on the link.
Using a tool like selenium has some drawbacks, though ; some of them are :
you need a machine with a graphic environnement, to launch the browsers (command line is not enough)
tests with selenium take time : browsing and using the application means loading all the CSS/JS/Images/ads/whatever, for each page ; like in a real browser -- because you are using a real browser
But these tests are quite nice, and usefull to test the application as a whole -- ie, more "functionnal tests" than "unit-test".