I am using Arquillian Drone + Graphene (standalone) for driving automated Browser Tests on a Selenium Grid 2.0 hosted on another machine. The tests are run via Arquillian in client mode (the server to be tested is already running)
Some of my tests require using two browsers at once, therefore i added a second Browser according to the Graphene Documentation.
So far everything is working.
The Problem:
Running a test which has both browsers injected has both of them started up before any test of the class is run. As there may be a few tests before the second browser is used, it most likely has already timed out.
Of course i could set the Selenium Grid Settings to never (or very late) close the browser via timeout, but that cannot be the solution.
Is there a way to check if the WebDriver is still up and restart it via Drone?
Without Drone i simply could check if the driver quit (e.g. like this) and create a new instance. But i want to have it injected via Drone.
In the best case i would like to be able to define when Drone should open the browser or even better keep it open until the test is finished.
If thats not possible a way to restart it would be sufficient.
I solved the Problem by directly injecting the WebDriver into the test method.
public void test(#Drone #Browser2 WebDriver webdriver){...}
I am still not completely happy with this solution but it does work.
When debugging a Selenium test I'll set a breakpoint, and usually run off to look at the DOM, and test xpaths. The problem is the browser times out after 90 seconds and goes away. How can I extend or disable this browser timeout so it stays open for long enough for me to do actual work in it?
I'm using the Java version of the API.
I do not want the browser to close simply because I'm sitting on a breakpoint and no commands are being sent to it.
update
we are using vaadin-testbench-standalone-4.0.3.jar hub/node scripts to run? selenium. Given comments I think this may be what's killing the browser. I see the hub output emitting this
13:58:02.152 INFO - Session 97ae07ab-ca71-4aa9-a2b1-9a75859f6c9b deleted due to client timeout
I'm building a system with a login. When I was just testing it on my own computer, it worked perfectly fine. Once I uploaded it to our server, we started running into the problem whereby ... it wouldn't log in in the morning, for a few seconds. Works fine the rest of the time.
I've only run into this yesterday and today, and I can only test it once each morning, so it's hard to give too many details yet. Here's the setup:
The front page is an html page using javascript and angular js. It brings up an empty frame, then makes an ajax request for the contents of the page. On any failed ajax request that has a return value of 'insufficient access priviliges' it will un-hide a div holding a login form. That login form blanks out the page and provides a submit button. Once the submit button is clicked on, it sends an ajax login request to the Java server. Once that request is returned, the page hides the login form again, and things move on as usual.
On the back end, we have a java server running something between 1.6 and 1.7 (yes, I know, I should know better - the server reports back that it's 1.7.001, but 1.7 functionality like string-based switch-case statements don't work, so we compile for 1.6 java when uploading. It's a known issue we're working on.) We're using Stripes to do the front-facing code. The database is a mysql database, located on the same server.
When this error occurs, it's always the first login in the morning. I load up the page, type in the user/pass, and click login. The page blinks and comes back to the login screen. I haven't cleared out the user/pass after a login yet, because we're still in a testing phase, so I can just click 'login' again, and again, a dozen times before it finally logs in. This problem has only happened twice: yesterday and today, the first login of the morning.
My co-worker had a similar issue with another similar setup on a previous project, same server. He said he believes the problem has to do with the sql server closing the connection without the java server realizing that the connection has been closed, but he's not sure, and doesn't know how to fix it.
I don't even know what other information to offer, what code to show, or anything like that. The best suggestion I can find anywhere is "Set up a scheduled event to make a sure-fire database request every couple of hours," but this seems so ... kludgy. I'd love to be able to test for a more definitive problem and solution, if anyone could help me out. If anyone can tell me what code they'd like to see to figure this out, I'll gladly paste it up. More information? Just ask. The scope seems so ... big ... that I don't know which pieces might be relevant.
Edit 1: Error code!
[ERROR] - Database Error 1 on verify
java.sql.SQLException: Already closed.
at org.apache.tomcat.dbcp.dbcp.PoolableConnection.close(PoolableConnection.java:114)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
Edit 2: Connection Code
This is from an object we keep specifically for all mysql database connections.
private static ConnectionSource coreConnection = null;
private static DataSource coreDataSource = null;
public static ConnectionSource getCoreConnection() throws SQLException, NamingException {
if (coreConnection == null || !coreConnection.isOpen()) {
Context env = (Context)new InitialContext().lookup("java:comp/env");
coreDataSource = (DataSource)env.lookup("webapps/test");
coreConnection = new DataSourceConnectionSource(coreDataSource, new MysqlDatabaseType());
}
return coreConnection;
}
Configure your connection pool to validate connections. The connection pool will then send a simple query (which you specify during configuration) to the DB. If that query fails, it will close the connection and give you a new one, otherwise it will use it in place. That helps solve problems like these as well as problems where the database goes down behind the back of the server.
MySQL closes connections which have been open for a long time, but don't do anything. From what you've described it sounds like this is what you're running in to.
The first login fails because it finds that the used database connection is no longer working, and the driver notices this as well. The driver will then use a new connection for the next request.
The first way to handle this that comes to mind is detecting this SQLException, and handling it by opening a new connection with the same query. There may be other solutions available within the driver that you're using, but unfortunately I am not aware of any.
To aid with detecting this SQLException you can take a look at the docs, and evaluate if the methods listed there return anything unique to this error.
If you are using a connection pool, then this question may contain the answer to keeping the connections alive.
We are in the process of creating a training mode for our ColdFusion (9) sites.
The system will allow our users, after logging in, to switch from production mode to training mode by clicking on a link.
When they switch, the data-sources will be switched allowing the data to be safely modified.
We are also going to implement a test SMTP server, using the SubEthaSMTP Java project, in order to capture the emails that are sent from the training mode and display them to the user in a web page.
We can launch the SMTP server as a stand alone process or service without much trouble.
The nicer solution would be to launch server as part of the ColdFuson runtime at the point that the user switches to training mode.
We would create a true Java thread that would persist on a Server level scope for the length of any training sessions and then some arbitrary time out period. If the server times out and a new training session is initiated we would initiate a new SMTP server.
My essential question is, therefore, is it a bad idea to run an ongoing thread in the ColdFusion runtime this way?
I can't see a problem with doing this, although you ought to test to see what resources SubEthaSMTP uses and make sure it's not going to cause you issues. It looks to have minimal dependencies (essentially just SLF4J, which ColdFusion 9 & 10 already provide)
From the example page it looks to be pretty easy to set up and drop into a long-running scope. I think you're right to pick the server scope, as you may have problems using application or anything more volatile, as there'll be a situation where application scope would timeout and be reset, but you'd loose all references to the Mail Server instance.
Please update the post with your findings, as I'd be interested in seeing what you find.
How to approach the following scenario?
Say a test is already running in selenium rc node on a remote server using RemoteWebDriver.
The test encounters a missing element (slightest xpath change across different pages).
User provides the correct xpath for that element (this part is done in the Java application running on the user's computer) and selenium test searches for the element again and continues with rest of the test.
First thing that comes to mind is that Selenium server is using Jetty server. How would I communicate between by client java application and this server? can Jetty be ignored and somehow make the client communicate directly with the running selenium test?
When the element can not be located by a given xpath the webdriver will throw an exception which will bubble back to where you are running your test. As long as you catch this exception you will have the chance to check different xpaths.
i guess you are looking for , halt the execution in the browser and continue that execution from where ever you want (from previous statement ), instead of the browser responding back to selenium RC and to client program.
-- you want to completely stop the browser response to the request made by the selenium RC
if this is correct can you please confirm, may be i can help you.