I have started building up my first Appium test in Android and for that, I started writing my code.
I instantiated my DesiredCapabilities
object but when I am trying to use that reference, I cant see that reference.
Link to Image for the issue:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.13.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Please help me what is missing in order to help to proceed with coding. Is any jar being missed which I need to associate?
You can not access the method using references directly, in the class because there is no execution entry point. You have to write your code within some method
, constructor
or in block
(static/non-static). Refer below examples :
Way I
DesiredCapabilities capabilities =DesiredCapabilities.android();
public FirstDemoClass() {
// TODO Auto-generated constructor stub
capabilities.setCapability("deviceName", "emulator-5554");
}
Way II
DesiredCapabilities capabilities =DesiredCapabilities.android();
// method
public void setCapabilities() {
capabilities.setCapability("deviceName", "emulator-5554");
}
Way III
static DesiredCapabilities capabilities = DesiredCapabilities.android();
// block
static {
capabilities.setCapability("deviceName", "emulator-5554");
}
public static void main(String[] args) {
}
This should work. let me know if any thing there.