Skip to content

Commit

Permalink
Fixed support with window pdf downloads
Browse files Browse the repository at this point in the history
Fixed issue in netapix command
Fixed issue with ui events
Version bump to 3.0.1
  • Loading branch information
Sumeet Chhetri authored and Sumeet Chhetri committed Sep 15, 2024
1 parent 1f6ab9e commit 2cfbde6
Show file tree
Hide file tree
Showing 25 changed files with 375 additions and 143 deletions.
8 changes: 2 additions & 6 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="alldep-jar/src/main/resources"/>
<classpathentry kind="src" path="alldep-jar/src/main/java"/>
<classpathentry kind="src" path="plugin/src/main/java"/>
<classpathentry exported="true" kind="src" path="/gatf-plugin"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
Expand Down
7 changes: 2 additions & 5 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,17 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
<filteredResources>
<filter>
<id>1633431844603</id>
<id>1723180336896</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
48 changes: 48 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"env": {
"java.jdt.ls.java.home": "/Users/sumeetc/.sdkman/candidates/java/11.0.14-tem"
},
"name": "ConfigTool",
"request": "launch",
"mainClass": "com.gatf.generator.core.GatfTestGeneratorUtil",
"args": "-configtool 9080 0.0.0.0 alldep-jar/sample",
"vmArgs" : "-Djdk.attach.allowAttachSelf=true", //it accepts a string or an array of strings,
"projectName": "gatf-alldep-jar"
},
{
"type": "java",
"env": {
"java.jdt.ls.java.home": "/Users/sumeetc/.sdkman/candidates/java/11.0.14-tem"
},
"name": "Command",
"request": "launch",
"mainClass": "com.gatf.selenium.Command",
"vmArgs" : "" //it accepts a string or an array of strings
},
{
"type": "java",
"env": {
"java.jdt.ls.java.home": "/Users/sumeetc/.sdkman/candidates/java/11.0.14-tem"
},
"name": "DisListener",
"request": "launch",
"mainClass": "com.gatf.executor.distributed.DistributedGatfListener",
"vmArgs" : "" //it accepts a string or an array of strings
},
{
"type": "java",
"name": "ConfigTool Debug (Remote)",
"projectName": "gatf-alldep-jar",
"request": "attach",
"hostName": "10.10.4.208",
"port": 8000
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"java.compile.nullAnalysis.mode": "disabled",
"java.jdt.ls.java.home": "/Users/sumeetc/.sdkman/candidates/java/11.0.23-tem",
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable",
"java.configuration.updateBuildConfiguration": "interactive"
}
6 changes: 5 additions & 1 deletion alldep-jar/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
4 changes: 2 additions & 2 deletions alldep-jar/.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
</natures>
<filteredResources>
<filter>
<id>1633431844598</id>
<id>1723180336885</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
2 changes: 1 addition & 1 deletion alldep-jar/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
2 changes: 1 addition & 1 deletion alldep-jar/src/main/java/com/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.gatf.selenium.SeleniumTest;
import com.gatf.selenium.SeleniumTestSession;

/*GATF_ST_CLASS_START_*/ @SuppressWarnings("serial")
/*GATF_ST_CLASS_START_*/
public class Validator extends SeleniumTest
implements Serializable {
public static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ public AcceptanceTestContext(DistributedAcceptanceContext dContext, ClassLoader
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
getWorkflowContextHandler().init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public DistributedConnection distributeContext(String node, AcceptanceTestContex

logger.info("Sending GATF configuration to node " + node);
oos.writeInt(Command.CONFIG_SHARE_REQ.ordinal());
DistributedAcceptanceContext.ser(oos, disContext);
DistributedAcceptanceContext.ser(oos, disContext);
oos.flush();
logger.info("Sent GATF configuration to node " + node);

Expand All @@ -91,6 +91,7 @@ public DistributedConnection distributeContext(String node, AcceptanceTestContex
conn.ois = ois;
conn.oos = oos;
logger.info("Sending GATF configuration Successful to node " + node);
ois.close();
} else {
logger.info("Sending GATF configuration Failed to node " + node);
}
Expand All @@ -102,7 +103,7 @@ public DistributedConnection distributeContext(String node, AcceptanceTestContex
try {
client.close();
} catch (IOException e1) {
e1.printStackTrace();
//e1.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ else if(authExtractAuthParams[3].equalsIgnoreCase("cookie"))
soapAction = soapAction != null ? "\"" + soapAction + "\"" : "";
builder.addHeader(AcceptanceTestContext.PROP_SOAP_ACTION_11, soapAction);
builder.addHeader(AcceptanceTestContext.PROP_CONTENT_TYPE, AcceptanceTestContext.MIMETYPE_TEXT_XML);
//TODO recheck this later builder.addParameter(AcceptanceTestContext.PROP_CONTENT_TYPE, AcceptanceTestContext.MIMETYPE_TEXT_XML);
testCase.getHeaders().put(AcceptanceTestContext.PROP_CONTENT_TYPE, AcceptanceTestContext.MIMETYPE_TEXT_XML);
} else if (request.contains(AcceptanceTestContext.SOAP_1_2_NAMESPACE)) {
String contentType = AcceptanceTestContext.MIMETYPE_APPLICATION_XML;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ public void handleEvent(Event currentEvent) {
.showTextAligned("Page " + pageNum, coordP, footerY, TextAlignment.RIGHT)
.close();
}

canvas.close();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
Expand Down Expand Up @@ -221,7 +221,6 @@ public String show() {
return builder.toString();
}

@SuppressWarnings("serial")
public List<Object> toList() {
return new ArrayList<Object>() {{
add(totalTestCount);
Expand Down
41 changes: 29 additions & 12 deletions alldep-jar/src/main/java/com/gatf/selenium/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected static class CommandState {
boolean isSTGenPhase = false;
boolean modeEnableGlobalTimeouts = true;
boolean modeEnableConcurrentWebDriver = false;
boolean hasNetapixCommand = false;

int NUMBER = 1;
int NUMBER_COND = 1;
Expand Down Expand Up @@ -115,7 +116,6 @@ protected static class CommandState {
String ifcnt = null, pifcnt = null;

List<Object[]> subtestDetails = new ArrayList<Object[]>();
@SuppressWarnings("serial")
Set<String> systemReservedKeys = new HashSet<String>() {{
add("loop over");
add("begin code in");
Expand Down Expand Up @@ -405,7 +405,6 @@ public String getClassName() {
return className;
}

@SuppressWarnings("serial")
public static class GatfSelCodeParseError extends GatfRunTimeError {
Object[] details;
List<GatfSelCodeParseError> multiple = new ArrayList<GatfSelCodeParseError>();
Expand Down Expand Up @@ -793,7 +792,7 @@ static Command parse(Object[] cmdDetails, CommandState state, Command parent) {
comd = new TimeoutCommand(cmd.substring(8), cmdDetails, state);
state.timeoutNum = ((TimeoutCommand)comd).counter;
state.ifTimeoutNum = ((TimeoutCommand)comd).ifCounter;
state.timeoutSleepGranularity = ((TimeoutCommand)comd).sleepGranularity;
state.timeoutSleepGranularity = ((TimeoutCommand)comd).sleepGranularity;
} else if (cmd.toLowerCase().startsWith("layer ")) {
comd = new LayerCommand(cmd.substring(6).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().equals("break")) {
Expand Down Expand Up @@ -824,16 +823,17 @@ static Command parse(Object[] cmdDetails, CommandState state, Command parent) {
comd = new WindowCommand(cmd.substring(7).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().startsWith("frame ")) {
comd = new FrameCommand(cmd.substring(6).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().startsWith("printpdf ")) {
} /*else if (cmd.toLowerCase().startsWith("printpdf ")) {
comd = new PrintPDFCommand(cmd.substring(9).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().startsWith("mail ")) {
}*/ else if (cmd.toLowerCase().startsWith("mail ")) {
comd = new MailCommand(cmd.substring(5).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().startsWith("http")) {
comd = new HttpCommand(cmd.substring(5).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().startsWith("wopensave ")) {
comd = new WindowOpenSaveInterceptJsCommand(cmd.substring(10).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().startsWith("netapix ")) {
comd = new NetworkAPIInterceptCommand(cmd.substring(8).trim(), cmdDetails, state);
state.hasNetapixCommand = true;
} else if (cmd.toLowerCase().startsWith("sleep ")) {
comd = new SleepCommand(cmd.substring(6).trim(), cmdDetails, state);
} else if (cmd.toLowerCase().matches(typeSwStr) || cmd.toLowerCase().matches(typeExStr) ||cmd.toLowerCase().startsWith("select ")
Expand Down Expand Up @@ -1249,6 +1249,13 @@ static void get(Command parent, ListIterator<Object[]> iter, CommandState state,
}
}
}
if(!f.exists()) {
f = new File(new File(parentPath).getParent() + File.separator + ((ImportCommand)tmp).name);
parentPath = new File(parentPath).getParent();
if(!f.exists() && new File(parentPath).exists()) {
f = new File(new File(parentPath).getParent() + File.separator + ((ImportCommand)tmp).name);
}
}
if(!f.exists()) {
f = new File(state.origBasePath + File.separator + ((ImportCommand)tmp).name);
}
Expand Down Expand Up @@ -1378,6 +1385,13 @@ static void get(Command parent, ListIterator<Object[]> iter, CommandState state,
}
}
}
if(!f.exists()) {
f = new File(new File(parentPath).getParent() + File.separator + ((DynPropsCommand)tmp).name);
parentPath = new File(parentPath).getParent();
if(!f.exists() && new File(parentPath).exists()) {
f = new File(new File(parentPath).getParent() + File.separator + ((DynPropsCommand)tmp).name);
}
}
if(!f.exists()) {
f = new File(state.origBasePath + File.separator + ((DynPropsCommand)tmp).name);
}
Expand Down Expand Up @@ -1546,6 +1560,9 @@ static Command read(File file, List<String> commands, AcceptanceTestContext cont
CommandState state = new CommandState();
state.origBasePath = context.getGatfExecutorConfig().getTestCasesBasePath();
state.basePath = state.origBasePath;
if(context.getGatfExecutorConfig().getGatfTestDataConfig()!=null && context.getGatfExecutorConfig().getGatfTestDataConfig().getGlobalVariables()!=null) {
state.dynProps.putAll(context.getGatfExecutorConfig().getGatfTestDataConfig().getGlobalVariables());
}
if(context.getGatfExecutorConfig().getTestCaseDir()!=null) {
state.testcaseDir = context.getGatfExecutorConfig().getTestCaseDir();
}
Expand Down Expand Up @@ -1884,7 +1901,7 @@ String javacode() {
b.append("}\ncatch(Throwable "+ex+")\n{");
state.isSTGenPhase = true;
//b.append("\ntry{");
//b.append(ex+".printStackTrace();\n");
//b.append(ex+".printStackTrace();\n");
//b.append("java.lang.System.out.println(\"_main_exec.png\");");
//ScreenshotCommand tm = new ScreenshotCommand("_main_exec.png", new Object[] {}, state, true);
//b.append(tm.javacode());
Expand Down Expand Up @@ -1914,9 +1931,9 @@ public static String genDebugInfo(Command c) {
} else if(c instanceof BrowserCommand) {
return "/*GATF_OP_LINE@" + esc(c.fileLineDetails[2].toString().trim())+":"+c.fileLineDetails[1] + "*/__set__cln__(\""+(esc(c.fileLineDetails[2].toString().trim())+":"+c.fileLineDetails[1])+"\");";
}
return "/*GATF_LINE@" + esc(c.fileLineDetails[2].toString().trim())+":"+c.fileLineDetails[1] + "*/__set__cln__(\""+(esc(c.fileLineDetails[2].toString().trim())+":"+c.fileLineDetails[1])+"\");";
return "/*GATF_LINE@" + esc(c.fileLineDetails[2].toString().trim())+":"+c.fileLineDetails[1] + "*/__set__cln__(\""+(esc(c.fileLineDetails[2].toString().trim())+":"+c.fileLineDetails[1])+"\");";
}
return "";
return "";
}

public static class ExecCommand extends Command {
Expand Down Expand Up @@ -4729,7 +4746,7 @@ String javacode() {
}
config.setArguments(config.getArguments()+ " --ignore-certificate-errors");
//if(System.getProperty("webdriver.http.factory")==null) {
// config.setArguments(config.getArguments()+ " --remote-allow-origins=*");
config.setArguments(config.getArguments()+ " --remote-allow-origins=*");
//}
if(!config.getName().equals("chrome")) {
String cargs = config.getArguments();
Expand Down Expand Up @@ -4982,7 +4999,7 @@ String javacode() {
else {
throwError(fileLineDetails, new RuntimeException("Invalid driver configuration specified, no browser found with name " + config.getName()));
}
b.append("initBrowser(get___d___(), logconsole, logdebug, lognw);\n");
b.append("initBrowser(get___d___(), logconsole, logdebug, lognw, "+state.hasNetapixCommand+");\n");

boolean isDocker = "true".equalsIgnoreCase(System.getProperty("D_DOCKER")!=null?System.getProperty("D_DOCKER"):System.getenv("D_DOCKER"));
if(isDocker) {
Expand Down Expand Up @@ -6840,7 +6857,7 @@ String toCmd() {
return "printpdf \"" + name + "\"" + (extractText?" text":"");
}
String javacode() {
return "\nprintToPdf(get___d___(), evaluate(\""+esc(name)+"\"), "+extractText+", \""+esc(colsep)+"\");\n";
return "\nprintToPdf(___cw___, evaluate(\""+esc(name)+"\"), "+extractText+", \""+esc(colsep)+"\");\n";
}
public static String[] toSampleSelCmd() {
return new String[] {
Expand Down Expand Up @@ -7046,7 +7063,7 @@ public static class NetworkAPIInterceptCommand extends Command {
String[] parts = cmd.trim().split("[\t ]+");
String mode = unSantizedUnQuoted(parts[0].trim(), state);
if(StringUtils.isBlank(mode) || !mode.toLowerCase().matches("on|off")) {
throwParseError(null, new RuntimeException("window.open save intercept command needs to be enabled/disabled, valid values on|off"));
throwParseError(null, new RuntimeException("netapix command needs to be enabled/disabled, valid values on|off"));
}
start = !mode.equalsIgnoreCase("off");
if(mode.equalsIgnoreCase("on") && parts.length<2) {
Expand Down
Loading

0 comments on commit 2cfbde6

Please sign in to comment.