sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #51010
Re: [Question #679226]: Keyboard frozen after script run --- need to press ctrl-alt-c
Question #679226 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/679226
Status: Needs information => Open
Chetan B gave more information on the question:
Hi,
Yes I type in command prompt ,below is the code.
Maven dependency:<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>*1.1.2*</version>
</dependency>
code :
package Devicetesting;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.FileUtils;
import org.apache.commons.net.util.Base64;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
import org.sikuli.script.*;
import org.sikuli.script.Screen;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.*;
//@Listeners(Listner.TestngListner.class)
public class Gcs23 extends Base {
public static WiniumDriver driver1;
public static String line = null;
public static String actualresult = "";
public static String expectedresult =
"df09020000000023edc2330870f8e7100010048e0890b3d51f300100000002007c17010902000700000500000b0200010700000500010b030040bd8052c1021076bffaad8520be7092354574d8d391";
public static int i;
public static boolean flag = false;
public static ExtentTest extentTest;
@Test
public static void Gcs23Fun() throws IOException, AWTException,
MalformedURLException, InterruptedException, IOException, FindFailed,
FileNotFoundException {
{
try {
// ExtentHtmlReporter reporter=new
ExtentHtmlReporter("./AdvancedReports/Advancedreport.html");
ExtentReports report = new
ExtentReports("./AdvancedReports/Advancedreport.html", true);
// logger.loadConfig(new
File("C:\\Users\\bodkec1\\IdeaProjects\\winium\\src\\test\\java\\Devicetesting\\Extentconfig.html"));
// System.getProperty("user.dir")+"\\extent-config.xml
report.loadConfig(new
File("C:\\Users\\bodkec1\\IdeaProjects\\winium\\src\\test\\java\\Devicetesting\\extent-config.xml"));
// ExtentTest logger1=new ExtentTest("Gcs23","Gcs23Fun");
extentTest = report.startTest("Gcs23");
// logger.startTest("")
//extent.attachReporter(reporter);
// reporter.loadConfig("./Devicetesting/Extentconfig.html");
// ExtentTest logger=extent.createTest("DeviceTest Gcs23");
// reporter.config().setDocumentTitle("Device Testing Report");
//FirstCommandprompt:
DesktopOptions option = new DesktopOptions();
option.setApplicationPath("C:\\Windows\\system32\\cmd.exe");
WiniumDriver driver = new WiniumDriver(new
URL("http://localhost:9999"), option);
driver.findElementByClassName("#32769").click();
driver.findElementByClassName("#32769").sendKeys("cd..");
driver.findElementByClassName("#32769").submit();
driver.findElementByClassName("#32769").sendKeys("cd..");
driver.findElementByClassName("#32769").submit();
driver.findElementByClassName("#32769").sendKeys("cd..");
driver.findElementByClassName("#32769").submit();
driver.findElementByClassName("#32769").sendKeys(" cd
dist-db-17-08-2018");
driver.findElementByClassName("#32769").submit();
// acb-r1.3.exe "entityfile_00-0F.yaml" 9089
driver.findElementByClassName("#32769").sendKeys("acb-r2.0.exe
\"entityfile_00-0F.yaml\" 9089");
driver.findElementByClassName("#32769").submit();
Thread.sleep(10000);
//Second Command Prompt:
DesktopOptions option1 = new DesktopOptions();
option1.setApplicationPath("C:\\Windows\\system32\\cmd.exe");
driver1 = new WiniumDriver(new
URL("http://localhost:9999"), option1);
driver.findElementByClassName("#32769").click();
driver1.findElementByClassName("#32769").sendKeys("cd..");
driver1.findElementByClassName("#32769").submit();
driver1.findElementByClassName("#32769").sendKeys("cd..");
driver1.findElementByClassName("#32769").submit();
driver1.findElementByClassName("#32769").sendKeys("echo
%date%-%time%");
driver1.findElementByClassName("#32769").submit();
Thread.sleep(3000);
driver1.findElementByClassName("#32769").sendKeys(" cd
dist-db-17-08-2018");
driver1.findElementByClassName("#32769").submit();
// acb-r1.3.exe "entityfile_00-0F.yaml" 9089
driver1.findElementByClassName("#32769").sendKeys("receive.exe
21020");
//
driver1.findElementByClassName("#32769").sendKeys("\"C:\\dist-db-17-08-2018\\test.txt\"
2>&1");
driver1.findElementByClassName("#32769").submit();
//Third CommandPrompt:
DesktopOptions option2 = new DesktopOptions();
option2.setApplicationPath("C:\\Windows\\system32\\cmd.exe");
WiniumDriver driver2 = new WiniumDriver(new
URL("http://localhost:9999"), option2);
driver2.findElementByClassName("#32769").click();
driver2.findElementByClassName("#32769").sendKeys("cd..");
driver2.findElementByClassName("#32769").submit();
driver2.findElementByClassName("#32769").sendKeys("cd..");
driver2.findElementByClassName("#32769").submit();
driver2.findElementByClassName("#32769").sendKeys("cd..");
driver2.findElementByClassName("#32769").submit();
driver2.findElementByClassName("#32769").sendKeys(" cd
dist-db-17-08-2018");
driver2.findElementByClassName("#32769").submit();
// "acb-r2.0.exe \"entityfile_00-0F.yaml\" 9089"
// acb-r1.3.exe "entityfile_00-0F.yaml" 9089
driver2.findElementByClassName("#32769").sendKeys("send.exe 127.0.0.1
9089 \"gcs23.yaml\"");
Thread.sleep(5000);
driver2.findElementByClassName("#32769").submit();
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_TAB);
Thread.sleep(2000);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_ALT);
Thread.sleep(4000);
// Thread.sleep(90000);
// Thread.sleep(32000);
// Thread.sleep(20000);
for (i = 0; i <= 0; i++) {
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_C);
Thread.sleep(3000);
extentTest.log(LogStatus.INFO,"Captured response
from respponse window");
//Notepad invoke
DesktopOptions option3 = new DesktopOptions();
option3.setApplicationPath("C:\\Windows\\system32\\Notepad.exe");
WiniumDriver driver3 = new WiniumDriver(new
URL("http://localhost:9999"), option3);
Thread.sleep(5000);
driver3.findElementByName("Untitled - Notepad").click();
// driver3.findElementById("Item 1").click();
driver.findElementByName("Edit").click();
Thread.sleep(3000);
driver.findElementByName("Paste").click();
Thread.sleep(2000);
driver.findElementByName("File").click();
driver.findElementByName("Save As...").click();
Thread.sleep(4000);
driver.findElementByName("File name:").click();
driver.findElementByName("File name:").clear();
driver.findElementByName("File
name:").sendKeys("C:\\Responses\\gcs23.txt");
driver.findElementByName("Save").click();
Thread.sleep(2000);
driver.findElementByName("Confirm Save As").click();
Thread.sleep(1000);
Robot robot1 = new Robot();
robot1.keyPress(KeyEvent.VK_TAB);
Thread.sleep(3000);
robot1.keyPress(KeyEvent.VK_ENTER);
driver.findElementByName("File").click();
driver.findElementByName("Exit").click();
String fileName = "C:\\Responses\\gcs23.txt";
int counter = 0;
FileReader fileReader = null;
fileReader = new FileReader(fileName);
BufferedReader bufferedReader = new
BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) {
counter++;
if (line.contains("FullData")) {
flag = true;
System.out.println("Base64" + line);
line = line.toString();
actualresult = line.substring(14);
System.out.println(actualresult);
break;
}
}
if (flag == true) {
break;
}
}
if (flag == false) {
String timeStamp = new
SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
File screenshot = ((TakesScreenshot)
driver1).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new
File("C:\\Screenshots\\Failed\\Gcs23" + timeStamp + ".png"));
extentTest.log(LogStatus.FAIL, "No response received");
extentTest.log(LogStatus.PASS,"Expected
Result:",expectedresult);
report.endTest(extentTest);
report.flush();
SoftAssert assert1 = new SoftAssert();
assert1.fail();
assert1.assertAll();
}
//String guid =
"3QAAAAAAAEERAAAAAN8JAgAAAAAj5axnCHD45xAAEASOCJCz1R8wAQAAAAIAoQ0BCQEBBwkABQgACwCLAHQUrYRoxljDjduMFw==";
byte[] decoded = Base64.decodeBase64(actualresult);
String Actualresult = Hex.encodeHexString(decoded);
System.out.println("Actual Result in Hexadecimal" +
Actualresult);
// Reporter.log("Actual Result:" + Actualresult);
String expectedresult1 = expectedresult.substring(0, 8);
String expectedresult2 = expectedresult.substring(24,
40);
String expectedresult3 = expectedresult.substring(42,
58);
String Actualresult1 = Actualresult.substring(0, 8);
System.out.println("expectedresult1" + expectedresult1);
System.out.println("Actualresult1" + Actualresult1);
String Actualresult2 = Actualresult.substring(24, 40);
System.out.println("expectedresult2" + expectedresult2);
System.out.println("Actualresult2" + Actualresult2);
String Actualresult3 = Actualresult.substring(42, 58);
System.out.println("expectedresult3" + expectedresult3);
System.out.println("Actualresult3" + Actualresult3);
if (Actualresult1.replaceAll("\\s+",
"").contains(expectedresult1.replaceAll("\\s+", "")) &&
(Actualresult2.replaceAll("\\s+",
"").contains(expectedresult2.replaceAll("\\s+", "")) &&
(Actualresult3.replaceAll("\\s+",
"").contains(expectedresult3.replaceAll("\\s+", ""))))) {
System.out.println("Expected Result Matches with
the actual result");
System.out.println("========================================================");
System.out.println("Actual Result1:" + Actualresult1);
System.out.println("Expected Result1:" + expectedresult1);
System.out.println("========================================================");
System.out.println("Actual Result2:" + Actualresult2);
System.out.println("Expected Result2:" + expectedresult2);
System.out.println("========================================================");
System.out.println("Actual Result3:" + Actualresult3);
System.out.println("Expected Result3:" + expectedresult3);
System.out.println("========================================================");
Reporter.log("Expected Result Matches with the
actual result");
Reporter.log("========================================================");
Reporter.log("Actual Result1:" + Actualresult1);
Reporter.log("Expected Result1:" + expectedresult1);
Reporter.log("========================================================");
Reporter.log("Actual Result2:" + Actualresult2);
Reporter.log("Expected Result2:" + expectedresult2);
Reporter.log("========================================================");
Reporter.log("Actual Result3:" + Actualresult3);
Reporter.log("Expected Result3:" + expectedresult3);
Reporter.log("========================================================");
String timeStamp = new
SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
File screenshot = ((TakesScreenshot)
driver1).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new
File("C:\\Screenshots\\Passed\\Gcs23" + timeStamp + ".png"));
Reporter.log(timeStamp);
SoftAssert assert1 = new SoftAssert();
assert1.assertEquals("pass", "pass");
assert1.assertAll();
} else {
System.out.println("Actual result does not match
with expected result");
String timeStamp = new
SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
File screenshot = ((TakesScreenshot)
driver1).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new
File("C:\\Screenshots\\Failed\\Gcs23" + timeStamp + ".png"));
SoftAssert assert1 = new SoftAssert();
assert1.fail();
assert1.assertAll();
}
} catch (FileNotFoundException ex) {
System.out.println(ex);
SoftAssert assert1 = new SoftAssert();
assert1.fail();
assert1.assertAll();
}
}
}
public static void main(String args[]) throws
org.sikuli.script.FindFailed, IOException, AWTException,
MalformedURLException, InterruptedException, IOException,
FileNotFoundException {
Gcs23.Gcs23Fun();
}
}
On Fri, Mar 15, 2019, 11:57 AM RaiMan <question679226@xxxxxxxxxxxxxxxxxxxxx>
wrote:
> Your question #679226 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/679226
>
> Status: Open => Needs information
>
> RaiMan requested more information:
> what version of SikuliX?
>
> How do you open the command prompt?
>
> Are you typing into the command prompt?
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/sikuli/+question/679226
>
> You received this question notification because you asked the question.
>
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.