
net.sourceforge.marathon.javafxagent.JavaFXAgent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marathon-javafx-agent Show documentation
Show all versions of marathon-javafx-agent Show documentation
Marathon JavaDriver agent for Java/FX applications
/*******************************************************************************
* Copyright 2016 Jalian Systems Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package net.sourceforge.marathon.javafxagent;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.json.JSONObject;
import javafx.scene.Node;
import javafx.stage.Stage;
import net.sourceforge.marathon.javafxagent.Device.Type;
import net.sourceforge.marathon.javafxagent.JavaFXTargetLocator.JFXWindow;
import net.sourceforge.marathon.javafxagent.css.FindByCssSelector;
public class JavaFXAgent implements IJavaFXAgent {
public static final Logger LOGGER = Logger.getLogger(JavaFXAgent.class.getName());
private static final String VERSION = "1.0";
private IDevice devices;
private JavaFXTargetLocator targetLocator;
private JOptions options;
private long implicitWait;
public JavaFXAgent() {
this(Device.Type.EVENT_QUEUE);
options = new JOptions(this);
}
public JavaFXAgent(Type type) {
devices = Device.getDevice(type);
targetLocator = new JavaFXTargetLocator(this);
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getDevices()
*/
@Override
public IDevice getDevices() {
return devices;
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getTitle()
*/
@Override
public String getTitle() {
return targetLocator.getTitle();
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getWindowHandles()
*/
@Override
public Collection getWindowHandles() {
return targetLocator.getWindowHandles();
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getWindowHandle()
*/
@Override
public String getWindowHandle() {
return targetLocator.getWindowHandle();
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#switchTo()
*/
@Override
public JavaFXTargetLocator switchTo() {
return targetLocator;
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#manage()
*/
@Override
public JOptions manage() {
if (options == null) {
options = new JOptions(this);
}
return options;
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getVersion()
*/
@Override
public String getVersion() {
return VERSION;
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getName()
*/
@Override
public String getName() {
return "javadriver";
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#deleteWindow()
*/
@Override
public void deleteWindow() {
targetLocator.deleteWindow();
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#findElement(java.lang.
* String)
*/
@Override
public IJavaFXElement findElement(String id) {
return targetLocator.findElement(id);
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#getActiveElement()
*/
@Override
public IJavaFXElement getActiveElement() {
return targetLocator.getActiveElement();
}
/*
* (non-Javadoc)
*
* @see net.sourceforge.marathon.javaagent.IJavaAgent#quit()
*/
@Override
public void quit() {
Timer timer = new Timer(true);
timer.schedule(new TimerTask() {
@Override
public void run() {
AccessController.doPrivileged(new PrivilegedAction
© 2015 - 2025 Weber Informatics LLC | Privacy Policy