
com.tascape.reactor.webui.task.SeleniumIdeCases Maven / Gradle / Ivy
/*
* Copyright 2015 - 2016 Nebula Bay.
*
* 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 com.tascape.reactor.webui.task;
import com.tascape.reactor.webui.comm.Firefox;
import com.tascape.reactor.webui.suite.SeleniumIdeSuite;
import com.tascape.reactor.task.AbstractCase;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.openqa.selenium.server.htmlrunner.HTMLLauncher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author linsong wang
*/
public abstract class SeleniumIdeCases extends AbstractCase {
private static final Logger LOG = LoggerFactory.getLogger(SeleniumIdeCases.class);
private final SeleniumServer seleniumServer;
public SeleniumIdeCases() throws Exception {
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setTrustAllSSLCertificates(true);
this.seleniumServer = SeleniumIdeSuite.getSeleniumServer();
}
protected boolean runSeleniumIdeFirefox(File html, String browserURL) throws Exception {
File tempDir = new File(html.getParentFile() + "/temp/");
tempDir.mkdir();
File suite = File.createTempFile("selenium-ide-temp-suite-", ".html", tempDir);
suite.deleteOnExit();
String content = SUITE_TEMPLATE.replaceAll("XXXXXXXXXXXXXXXXXXXX", html.getName());
FileUtils.write(suite, content);
LOG.debug("Temp suite file {}", suite.getAbsolutePath());
File result = this.saveIntoFile("ide-result", "html", "");
this.captureScreens(2000);
HTMLLauncher launcher = new HTMLLauncher(this.seleniumServer);
String ff = "*firefox";
String bin = sysConfig.getProperty(Firefox.SYSPROP_FF_BINARY);
if (bin != null) {
ff += " " + bin;
}
String pf = launcher.runHTMLSuite(ff, browserURL, suite.toURI().toURL().toString(), result, 36000, true);
suite.delete();
return "PASSED".equals(pf);
}
private static final String SUITE_TEMPLATE = new StringBuilder()
.append("\n")
.append("\n")
.append("\n")
.append("\n")
.append(" \n")
.append(" Suite \n" + "\n" + "\n")
.append("\n")
.append("Suite \n")
.append("XXXXXXXXXXXXXXXXXXXX \n")
.append("
\n" + "\n" + "").toString();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy