using a remote Selenium server from Selenium test cases written in groovy - groovy

I've used Selenium ide to record test cases, export them to Groovy source, modify as necessary and run them. The default code expects a server on localhost, I'd like to use a server on a remote machine. How can I do this? When looking at the doc for GroovySeleneseTestCase it does not appear there is a setUp() method that allows you to use a remote server. The only option I can think of is setting a server host and port through the default selenium object in my setUp() method but am not sure how to do this.

In Java:
HttpCommandProcessor processor = new HttpCommandProcessor("localhost", 3300, browserName, appBaseURL);
selenium = new CustomSelenium(processor, browserName, waitToLoadTimeout, waitForConditionTimeout);
selenium.start();
just replace localhost and 3300 by the server's address and the correct port. I don't know Groovy, but it shouldn't be much different. Of course, the server has to be started first and the firewall configured.

In order to get this to work I had to create a custom instance of GroovySelenium, assign it to the test class, and not call the super.setUp method. Code example follows.
void setUp(String selServer, int selPort, String browser, String basePath) throws Exception {
def tempSel=new DefaultSelenium(selServer, selPort, browser, basePath)
selenium= new GroovySelenium(tempSel)
selenium.start()
setDefaultTimeout(30000)
setCaptureScreenshotOnFailure(false)
}
Assuming you have this setup method in a class called MyTest, want to test google.com using a selenium server with host name myserver, port 5555, and using internet explorer as the browser the following code would work.
test=New MyTest()
test.setUp("myserver",5555,"*iexplore","http://www.google.com")
test.testMyTest()

Related

How to get the VNC connection status?

I have been looking to find a way for my Qt application to know if a VNC connection is active.
How/can I get a VNC connection status?
This is an embedded Linux application.
A starting point would be to look into the Qt sources at src/plugins/gfxdrivers/vnc/qscreenvnc_p.h; there a class QVNCServer is declared that also defines a isConnected() method which appears to do exactly what you need.
The crucial point, however, is to access that method from your application code; as can be deducted from the filename suffix _p the classes in that header are private (read: internal) to the Qt libs and not part of the public interface. Accordingly they are not documented in the reference, and I haven't found a public method to get the current QVNCServer object, nor any other VNC related instance that could provide a pointer to that object.
My suggestion is that you start with the related public interface in src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h, which incorporates the server class as part of a QProxyScreen subclass, and work onwards from there to get an idea how the VNC server instance is created, and where the pointer to it is handled. You may be able to add a method to the QVNCScreen interface which allows you to get the connection state from your application. However you'll have to patch the Qt sources and rebuild the libraries.
Getting the QScreen object in application code is easy:
foreach(const QScreen* s, QScreen::instance()->subScreens())
{
if(s->classId() == QScreen::VNCClass)
//Here you can cast the screen instance and call a method on it
}

Get web application ip and port on ServletContextListener

I want to get my web application ip and port on start of server? For example within my ServletContextListener class. But i could not get them using neither FaceContext nor ServletContextEvent.
FacesContext.getCurrentInstance().getExternalContext().getRequestServerName()
Using code like above will result in Unsupported method.
Since it need for a thread which run from the start of our application, we could not wait until some request send to our server.
Our application using jsf2, primeface and run on weblogic 10.3.6
You need to access the HttpServletRequest, like this:
HttpServletRequest request = ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest());
request.getLocalAddr();
request.getLocalPort();

How to use the ChromeApp to connect to a node.js server?

I have a Node.js server and I'd like to know how I could do for the ChromeApp to work with it. I tried putting "http://localhost:3000" (server address) on the runtime:
chrome.app.runtime.onLaunched.addListener(function () {
chrome.app.window.create('http://localhost:3000');
});
But it doesn't even launch. Does someone have an idea on what I could do?
Thanks.
You cannot launch external URLs with chrome.app.window.create. In fact if you check the chrome.runtime.lastError property you will see the following error:
The URL used for window creation must be local for security reasons.
I suggest you look into using the <webview> tag as it is much more appropriate for your use-case.

Resolve mDNS .local URL in browser address bar

I am trying to run a HTTP server in my LAN and want to access it by using a browser on another desktop machine. As I do not like typing the IP address and port manually I tried setting up a mDNS using jmDNS.
String type = "_http._tcp.local.";
jmdns = JmDNS.create();
jmdns.addServiceListener(type, listener = new ServiceListener() {
#Override
public void serviceResolved(ServiceEvent ev) {
Log.d(LogTag.SERVER, "Service resolved: " + ev.getInfo().getQualifiedName() + " port:"
+ ev.getInfo().getPort());
}
#Override
public void serviceRemoved(ServiceEvent ev) {
Log.d(LogTag.SERVER, "Service removed: " + ev.getName());
}
#Override
public void serviceAdded(ServiceEvent event) {
// Required to force serviceResolved to be called again (after the first search)
jmdns.requestServiceInfo(event.getType(), event.getName(), 1);
}
});
serviceInfo = ServiceInfo.create(type, NAME, PORT, "test service");
jmdns.registerService(serviceInfo);
The mDNS entry shows up on ZeroConf Browser app just fine. The server is reachable by IP and port just fine.
On Windows 7 typing the name with the .local TLD (= http://roseblade.local/) into any address bar (Firefox, Chrome, Safari, IE) does not do much and from what my research shows is pretty much a futile task anyway. I installed Apple Bonjour but that only help running Hobbyist Software's Bonjour Browser.
As far as Linux goes I tried the same with elemantaryOS and Midori but that also did not work.
OSX or iOS is currently not available to me.
How can I get the resolution of the .local address to work in my browser (Firefox, Chrome, whatever on Linux, OSX or Windows7)? Am I doing something wrong? At this point I would just like to verify that mDNS can work like that on a system.
Pointers to material on the issue are also appreciated.
mDNS and Bonjour can be a little confusing because they actually encompass a few different functionalities. Service discovery, which I believe is what you have implemented, is one. Resolving an address--which is what you're looking for--is separate, and needs to be solved separately. Once you have address resolution working, you can point your service discovery at the DNS records provided by your resolver.
mDNS address resolution works by multicasting a DNS query over the network. By binding to a UDP port, listening for queries, and answering them, you can provide DNS records to mDNS clients. To do this, you can use an existing mDNS server like avahi-daemon, or, if you need custom functionality or integration with your application, implement one using something like Node.js's multicast-dns.
However, in my experience, this has been rather flakey. Some network configurations interfere with mDNS resolution, as do some OSes (eg. iOS 8, see the whole debate around discoveryd vs. mDNSResponder).

How do I check custom TURN server is working with easyRTC

I am working on an application for Audio/Video calls using easyrtc.
I have added turn server details in server.js file to configure the turn servers I want to use.
var myIceServers = [
{url: "stun:stun.anyfirewall.com:3478"},
{url: "turn:turn.anyfirewall.com:443", "username":"xxxxx", "credential":"xxxxx"},
{url: "turn:turn.anyfirewall.com:443?transport=tcp", "username":"xxxxx", "credential":"xxxxx"}
];
then set options for appIceServers using below line of code.
easyrtc.setOption("appIceServers", myIceServers);
and configured the listener as well.
easyrtc.on("getIceConfig", function(connectionObj, callback){
callback(null, myIceServers);
}
After this when I am running easyrtc simple audio-video demo, from local machine, in chrome using two tabs it works fine.
Now I have two questions:
How do I make sure that easyrtc is using custom supplied TURN server configuration ?
And from where I need to test the links for my application, which will make sure that easyrtc is using custom supplied TURN url for tcp ? (i.e. firewall check).
You can turn the "log level" to "3" in server.js to see more detail logs, and use chrome://werbrtc-internals to see the chrome webrtc logs . I just set up a TURN server yesterday and in my way , I modified the easyrtc_default_options to using my own TURN,I think your configuration will work if you test with two client in different network, the Turn server will give you a feedback.
"from local machine, in chrome using two tabs it works fine." this is not using you TURN server.

Resources