Calculator getting launched but tests are not Executing - java
See original GitHub issueHi,
When I run the test using calculator sample calculator application getting launched but no tests are getting executed. Could you please help me to solve it…
Dev Environment
-
Windows 10 (Enterprise)
-
Java -1.8
-
Selenium Java: 3.4.0
-
appium -1.6.6-beta (install using node)
-
eclipse
Steps I did
1.Manually run the winAppDriver.exe using CMD in administrator mode 2.Changed WindowsDriver instead of IOSDriver 3.Run the java class test using JUnit –> Then, App getting launched, but tests are not executed.
WinAppDriver Log
C:\Program Files (x86)\Windows Application Driver>WinAppDriver.exe
Windows Application Driver Beta listening for requests at: http://127.0.0.1:4723/
Press ENTER to exit.
==========================================
POST /session HTTP/1.1
Accept-Encoding: gzip,deflate
Connection: Keep-Alive
Content-Length: 330
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:4723
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
{"capabilities":[{"desiredCapabilities":{"app":"microsoft.windowscalculator_8wekyb3d8bbwe!app","platformName":"Windows","deviceName":"WindowsPC"}},{"requiredCapabilities":{}}],"desiredCapabilities":{"app":"microsoft.windowscalculator_8wekyb3d8bbwe!app","platformName":"Windows","deviceName":"WindowsPC"},"requiredCapabilities":{}}
SessionManager - Creating session for microsoft.windowscalculator_8wekyb3d8bbwe!app
SessionManager - WinAppDriver succeeded loading MitaBroker
SessionManager - Application launched
SessionManager - Session successfully created: 8955D6B6-3E43-46B0-8F61-93AA9B38E05F
HTTP/1.1 200 OK
Content-Length: 127
Content-Type: application/json
{"sessionId":"8955D6B6-3E43-46B0-8F61-93AA9B38E05F","status":0,"value":{"app":"microsoft.windowscalculator_8wekyb3d8bbwe!app"}}
==========================================
GET /session/8955D6B6-3E43-46B0-8F61-93AA9B38E05F HTTP/1.1
Accept-Encoding: gzip,deflate
Cache-Control: no-cache
Connection: Keep-Alive
Host: 127.0.0.1:4723
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
HTTP/1.1 404 Not Found
Console Log
org.openqa.selenium.UnsupportedCommandException: Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'LKCONVSELVARA01', ip: '10.83.68.58', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities [{app=microsoft.windowscalculator_8wekyb3d8bbwe!app, javascriptEnabled=true, platform=ANY}]
Session ID: 3097CDD5-C282-4523-8917-3EC0F4FC67E2
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1)
at io.appium.java_client.HasSessionDetails.getSessionDetails(HasSessionDetails.java:36)
at io.appium.java_client.HasSessionDetails.getSessionDetail(HasSessionDetails.java:42)
at io.appium.java_client.HasSessionDetails.getPlatformName(HasSessionDetails.java:46)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:100)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:112)
at io.appium.java_client.windows.WindowsDriver.<init>(WindowsDriver.java:43)
at CalculatorTest.setup(CalculatorTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
My Code
import org.junit.*;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.util.concurrent.TimeUnit;
import java.net.URL;
import io.appium.java_client.windows.WindowsDriver;
public class CalculatorTest {
private static WindowsDriver CalculatorSession = null;
private static WebElement CalculatorResult = null;
@BeforeClass
public static void setup() {
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", "microsoft.windowscalculator_8wekyb3d8bbwe!app");
capabilities.setCapability("platformName", "Windows");
capabilities.setCapability("deviceName", "WindowsPC");
CalculatorSession = new WindowsDriver (new URL("http://127.0.0.1:4723"), capabilities);
CalculatorSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
CalculatorSession.findElementByName("Clear").click();
CalculatorSession.findElementByName("Seven").click();
CalculatorResult = CalculatorSession.findElementByName("Display is 7");
Assert.assertNotNull(CalculatorResult);
}catch(Exception e){
e.printStackTrace();
} finally {
}
}
@Before
public void Clear()
{
CalculatorSession.findElementByName("Clear").click();
Assert.assertEquals("Display is 0", CalculatorResult.getText());
}
@AfterClass
public static void TearDown()
{
CalculatorResult = null;
if (CalculatorSession != null) {
CalculatorSession.quit();
}
CalculatorSession = null;
}
@Test
public void Addition()
{
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("Plus").click();
CalculatorSession.findElementByName("Seven").click();
CalculatorSession.findElementByName("Equals").click();
Assert.assertEquals("Display is 8", CalculatorResult.getText());
}
@Test
public void Combination()
{
CalculatorSession.findElementByName("Seven").click();
CalculatorSession.findElementByName("Multiply by").click();
CalculatorSession.findElementByName("Nine").click();
CalculatorSession.findElementByName("Plus").click();
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("Equals").click();
CalculatorSession.findElementByName("Divide by").click();
CalculatorSession.findElementByName("Eight").click();
CalculatorSession.findElementByName("Equals").click();
Assert.assertEquals("Display is 8", CalculatorResult.getText());
}
@Test
public void Division()
{
CalculatorSession.findElementByName("Eight").click();
CalculatorSession.findElementByName("Eight").click();
CalculatorSession.findElementByName("Divide by").click();
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("Equals").click();
Assert.assertEquals("Display is 8", CalculatorResult.getText());
}
@Test
public void Multiplication()
{
CalculatorSession.findElementByName("Nine").click();
CalculatorSession.findElementByName("Multiply by").click();
CalculatorSession.findElementByName("Nine").click();
CalculatorSession.findElementByName("Equals").click();
Assert.assertEquals("Display is 81", CalculatorResult.getText());
}
@Test
public void Subtraction()
{
CalculatorSession.findElementByName("Nine").click();
CalculatorSession.findElementByName("Minus").click();
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("Equals").click();
Assert.assertEquals("Display is 8", CalculatorResult.getText());
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Calculator getting launched but tests are not Executing - java
Hi, When I run the test using calculator sample calculator application getting launched but no tests are getting executed.
Read more >No tests found for given includes Error, when running ...
But why? I have a Spring (not Spring Boot) project where org.junit.Test works just fine. But now I created a Boot project with...
Read more >Why Maven Doesn't Find JUnit Tests to Run
When working with Maven projects, it's common for a developer to make a mistake that results in JUnit tests not running during a...
Read more >Java Unit Testing with JUnit and TestNG
Run Test case (or Test Suite): To run a test case (or test suite), right-click the file ⇒ Run As ⇒ JUnit Test....
Read more >Multiple Ways To Execute JUnit Tests
This Tutorial shows Multiple ways of Executing JUnit tests such as Running as a JUnit Test, Using Shortcut Keys, or Run JUnit Test...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments