Selenium WebDriver NoElementException while initializing - java

I have next code:
package pageobjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.safari.SafariDriver;
public class MainPage {
WebDriver driver = new SafariDriver();
private String baseURL = "https://www.amazon.com";
private WebElement searchLine = driver.findElement(By.cssSelector("#twotabsearchtextbox"));
private WebElement searchButton = driver.findElement(By.cssSelector("input.nav-input"));
public MainPage(){
driver.get(baseURL);
}
public void searchItem(String query){
searchLine.clear();
searchLine.sendKeys(query);
searchButton.click();
}
}
And test:
import org.testng.annotations.Test;
import pageobjects.MainPage;
public class FirstSimpleTest {
#Test
public void verifySearchWork(){
MainPage mainPage = new MainPage();
mainPage.searchItem("Nike Air Max");
}
}
Before browser runs I have next exception:
org.openqa.selenium.NoSuchElementException:
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'Macbook.connectify', ip: 'fe80:0:0:0:1029:e2f6:81bd:b9e1%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.2', java.version: '11'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 12.0.2, javascriptEnabled: true, platform: MAC, platformName: MAC, setWindowRect: true}
Session ID: 19412DA2-A6E4-40D5-89BE-1CE9310B8697
*** Element info: {Using=css selector, value=#twotabsearchtextbox}
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:322)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:416)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:314)
at pageobjects.MainPage.<init>(MainPage.java:14)
at FirstSimpleTest.verifySearchWork(FirstSimpleTest.java:8)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
How can I fix it?

before using driver do get an WebElement, you should get a reference by www-address
so use driver to get WebElement after invoke get(baseUrl)
private WebElement searchLine;
public MainPage(){
driver.get(baseURL);
searchLine = driver.findElement(By.cssSelector("#twotabsearchtextbox"));
}

Related

RemoteWebDriver throws = SessionNotCreatedException : Unable to create session from org.openqa.selenium.remote.NewSessionPayload#57ab6ec1

I'm trying to run a test using Opera browser as a node, hub and node connections are succesful.
Below is for hub and node connections:
Hub > java -jar selenium-server-standalone-3.9.1.jar -role hub
Node > java -Dwebdriver.opera.driver=C:\zip\exe\operadriver_win64\operadriver_win64\operadriver.exe -jar selenium-server-standalone-3.9.1.jar -role node -hub http://192.168.1.10:4444/grid/register -port 5566
When trying to executing the program two Opera browser loads but only blank white pages shown with Not secure data:; on URL and I am also getting this kind of exception.
org.openqa.selenium.SessionNotCreatedException: Unable to create session from org.openqa.selenium.remote.NewSessionPayload#6153fbda
Opera driver and Opera Browser I'm using:
Opera Version: 82.0.4227.58
Opera Driver Version : 96.0.4664.45
Below is the code used:
package Grid;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.*;
public class OperaNode {
static WebDriver driver;
String nodeUrl;
#SuppressWarnings("deprecation")
#BeforeTest
public void OpenBrowser() throws InterruptedException {
try {
nodeUrl = "http://192.168.1.10:5566/wd/hub";
DesiredCapabilities capabilities = DesiredCapabilities.opera();
capabilities.setBrowserName("opera");
capabilities.setPlatform(Platform.WINDOWS);
driver = new RemoteWebDriver(new URL(nodeUrl), capabilities);
driver.manage();
driver.get("http://www.yahoo.com");
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(2000);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
#Test
public void SigninButton() throws InterruptedException {
try {
driver.findElement(By.xpath("//a[#class='_yb_duqkn']")).click();
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
#AfterTest
public void CloseBrowser() {
driver.quit();
}
}
Below is the console Message:
FAILED CONFIGURATION: #BeforeTest OpenBrowser
org.openqa.selenium.SessionNotCreatedException: Unable to create session from org.openqa.selenium.remote.NewSessionPayload#6153fbda
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'DESKTOP-KML9RV5', ip: '192.168.1.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.2'
Driver info: driver.version: unknown
Command duration or timeout: 1.94 seconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at Grid.OperaNode.OpenBrowser(OperaNode.java:36)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:637)
at org.testng.TestRunner.beforeRun(TestRunner.java:627)
at org.testng.TestRunner.run(TestRunner.java:589)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create session from org.openqa.selenium.remote.NewSessionPayload#6153fbda
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'DESKTOP-KML9RV5', ip: '192.168.1.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.2'
Driver info: driver.version: unknown
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'DESKTOP-KML9RV5', ip: '192.168.1.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.2'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$4(NewSessionPipeline.java:75)
at java.util.Optional.orElseThrow(Optional.java:403)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$5(NewSessionPipeline.java:74)
at java.util.Optional.orElseGet(Optional.java:364)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:72)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:65)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:242)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.lang.Thread.run(Thread.java:831)
The RemoteWebDriver url configuration should always be routed to the hub, if using the Selenium Grid setup as your browser stack. The hub will then check for a node which matches your browser request and forward onto that node.
nodeUrl = "http://<hub ip address>:4444/wd/hub";
DesiredCapabilities capabilities = DesiredCapabilities.opera();
capabilities.setBrowserName("opera");
capabilities.setPlatform(Platform.WINDOWS);
driver = new RemoteWebDriver(new URL(nodeUrl), capabilities);

Selenium No such element exception despite not using or calling the WebElement [duplicate]

This question already has answers here:
NoSuchElementException, Selenium unable to locate element
(3 answers)
Closed 1 year ago.
Now I am executing a test case but am getting a NoSuchElementException despite not using that element in my test case. Here is my implementation.
This is my page layer
public class NotificationsPage extends BasePage {
private final WebElement datePicker =
driver.findElement(By.xpath("(//input[#aria-label='Password2'])[1]"));
public String textBoxData = "";
public String date1 = "";
public String date2 = "";
private final WebElement notificationTitle = driver.findElement(By.xpath("//a[#class='pmd-list-title']"));
{
textBoxData = datePicker.getAttribute("value");
String[] parts = textBoxData.split("-");
date1 = parts[0].trim();
date2 = parts[1].trim();
}
public String getNotificationTitle()
{
String title = notificationTitle.getText();
return title;
}
}
This is my test case I'm executing
#Test
public void testDateSettings(Map<String, String> map) throws Exception
{
try
{
new LoginPage().clickLoginButton().setUserName(map.get("username")).setPassword(map.get("password")).clickSubmit()
.clickHighlights();
}
catch(ExceptionInInitializerError ex)
{
ex.printStackTrace();
}
NotificationsPage notificationsPage = new NotificationsPage();
String systemDate = DateTimeUtils.getSystemDate();
System.out.println("System date:: "+systemDate);
System.out.println("Date1:: "+notificationsPage.date1);
System.out.println("Date2:: "+notificationsPage.date2);
Assertions.assertThat(systemDate).isBetween(notificationsPage.date1, notificationsPage.date2);
}
Now as you can see I am nowhere using the element notificationTitle in this particular test case but it is still giving me NoSuchElementException for that WebElement. Here is the stack trace
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//a[#class='pmd-list-title']"}
(Session info: chrome=94.0.4606.81)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-R3JT7MO', ip: '192.168.0.103', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 94.0.4606.81, chrome: {chromedriverVersion: 94.0.4606.61 (418b78f5838ed..., userDataDir: C:\Users\CHINMA~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:65399}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: b059694161fd932a928a64dc2c56d31d
*** Element info: {Using=xpath, value=//a[#class='pmd-list-title']}
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at com.digicorp.pageobjects.NotificationsPage.<init>(NotificationsPage.java:15)
at com.digicorp.pageobjects.HomePage.clickHighlights(HomePage.java:77)
at com.digicorp.testcases.TC_HighlightsSection.testDateSettings(TC_HighlightsSection.java:37)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Can someone shed some light on where I am making a mistake.
You should not declare like this,
private final WebElement notificationTitle = driver.findElement(By.xpath("//a[#class='pmd-list-title']"));
whenever the class is initializing, driver will start find this element, then resulted as NoSuchElementException
Declare the by and call it whereever you need,
private final By notificationTitleTxt = By.xpath("//a[#class='pmd-list-title']");
call this like on your method,
driver.findElement(notificationTitleTxt).getText();
What I would do here is
Use try-catch
Use findElements
Sample code for findElements
private final List<WebElement> notificationTitle = driver.findElements(By.xpath("//a[#class='pmd-list-title']"));
and in your instance initialize block
public String getNotificationTitle()
{
String title = notificationTitle.get(0).getText();
return title;
}
or why not simply try and catch block ?
try {
private final WebElement notificationTitle =
driver.findElement(By.xpath("//a[#class='pmd-list-title']"));
}
catch(ExceptionInInitializerError ex){
ex.printStackTrace();
}

Appium - #FindBy does not identify element - org.openqa.selenium.NoSuchElementException: Can't locate an element by this strategy

creating a page factory setup in Appium, the script cannot detect elements on screen.
So far tried:
Changing AndroidDriver to AppiumDriver
Swapping between #AndroidFindBy and #FindBy
Here are details of code:
1: Initial class (Note - Global Setup has all the desired capabilities and driver initiation)
public class TC01_HomePage extends GlobalSetup {
#Test
public void HomePages() throws IOException, InterruptedException
{
AndroidDriver<AndroidElement> driver = GlobalSetup.Capabilities();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WelcomePageObjects welcome = new WelcomePageObjects(driver);
welcome.verifyWelcomePage();
}
}
2: This is how WelcomePageObjects class looks like
public class WelcomePageObjects {
AndroidDriver<AndroidElement> driver;
public WelcomePageObjects(AndroidDriver<AndroidElement> driver)
{
this.driver = (AndroidDriver<AndroidElement>)driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
//Registration Button
#FindBy(xpath="//android.widget.TextView[#text='Register']")
private AndroidElement registerBtn;
public void verifyWelcomePage()
{
Assert.assertTrue(registerBtn.isDisplayed());
}
3: This is uiautomatorview of the element
4: This is the Eclipse error
org.openqa.selenium.NoSuchElementException: Can't locate an element by this strategy: By.xpath: //android.widget.TextView[#text='Register']
at io.appium.java_client.pagefactory.AppiumElementLocator.findElement(AppiumElementLocator.java:126)
at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.intercept(InterceptorOfASingleElement.java:59)
at io.appium.java_client.android.AndroidElement$$EnhancerByCGLIB$$b598166c.isDisplayed(<generated>)
at app.pom.pages.WelcomePageObjects.verifyWelcomePage(WelcomePageObjects.java:88)
at Android.APPII.TC01_HomePage.HomePages(TC01_HomePage.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(Unknown Source)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: org.openqa.selenium.TimeoutException: Expected condition failed: waiting for io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction#517566b (tried for 1 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:304)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
at io.appium.java_client.pagefactory.AppiumElementLocator.waitFor(AppiumElementLocator.java:99)
at io.appium.java_client.pagefactory.AppiumElementLocator.findElement(AppiumElementLocator.java:119)
... 32 more
Caused by: org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DELL-PC', ip: '192.168.1.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_261'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: com.appii.SplashActivity , appPackage: com.appii, automationName: uiautomator2, databaseEnabled: false, desired: {appActivity: com.appii.SplashActivity , appPackage: com.appii, automationName: uiautomator2, deviceName: Android Device, platformName: android}, deviceApiLevel: 29, deviceManufacturer: samsung, deviceModel: SM-A750F, deviceName: 3200fe04ba2c95cf, deviceScreenDensity: 420, deviceScreenSize: 1080x2220, deviceUDID: 3200fe04ba2c95cf, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, pixelRatio: 2.625, platform: LINUX, platformName: Android, platformVersion: 10, statBarHeight: 63, takesScreenshot: true, viewportRect: {height: 2031, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: 36bfeb30-8630-44b3-b6d5-61ecaa6029d3
*** Element info: {Using=xpath, value=//android.widget.TextView[#text='Register']}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:151)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:57)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.pagefactory.bys.ContentMappedBy.findElement(ContentMappedBy.java:50)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:57)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.pagefactory.AppiumElementLocator.lambda$0(AppiumElementLocator.java:120)
at io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction.apply(AppiumElementLocator.java:172)
at io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction.apply(AppiumElementLocator.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
... 34 more

"org.openqa.selenium.WebDriverException" Error displayed in the code

I am unable to find what is the cause of the error "org.openqa.selenium.WebDriverException" in my code, Please help me find and understand the cause much better. Firstly I would like to explain my code, It is a simple code where I go to a website click on "Sign In" link and then click on a text "Email" text field for registration purpose. I have used Page Factory in this code.
I have 3 files.
- Base file (Before and After methods)
- Registration File (Object repository and methods)
- Registration_Testcase File (Calling the methods)
Note: Base and Registration Testcase classes are in one package and Registration is in another package.
**Below is my code:**
Base Class
package testcases;
import org.testng.annotations.BeforeTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
public class Base {
public WebDriver driver;
public WebDriverWait wait;
#BeforeTest
public void beforeTest() {
ProfilesIni pro = new ProfilesIni();
FirefoxProfile ffProfile = pro.getProfile("vishvesh");
ffProfile.setAcceptUntrustedCertificates(true);
ffProfile.setAssumeUntrustedCertificateIssuer(false);
String base_url = "http://automationpractice.com/index.php";
System.setProperty("webdriver.gecko.driver", "G:/Workplace/AutomationSetupFiles/Geckdriver/geckodriver.exe");
driver = new FirefoxDriver();
driver.get(base_url);
}
#AfterTest
public void afterTest() {
driver.close();
}
}
Registration Class
package pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import testcases.Base;
public class Registration extends Base{
#FindBy(xpath="//*[#id='header']/div[2]//div[1]/a")
WebElement SignIn;
#FindBy(xpath="//input[#id='email_create']")
WebElement Registration_Email;
public Registration(WebDriver driver){
this.driver=driver;
PageFactory.initElements(driver, this);
}
public void ClickSignIn(){
//wait.until(ExpectedConditions.visibilityOf(SignIn)).click();
SignIn.click();
}
public void EnterEmail(String y){
//wait.until(ExpectedConditions.visibilityOf(Registration_Email)).click();
Registration_Email.click();
Registration_Email.sendKeys(y);
}
}
Registration TestCase Class
package testcases;
import org.testng.annotations.Test;
import pages.Registration;
public class Registatration_testcase extends Base{
#Test
public void f() {
Registration regobj = new Registration(driver);
regobj.ClickSignIn();
regobj.EnterEmail("amdv1991#gmail.com");
}
}
Error What I get:
FAILED CONFIGURATION:
#BeforeTest beforeTest
org.openqa.selenium.WebDriverException:
Build info: version: 'unknown', revision: '8c03df6', time: '2017-03-02 09:32:39 -0800'
System info: host: 'LAPTOP-SCJ4OHK5', ip: '192.168.1.3', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\VISHVE~1\AppData\Local\Temp\rust_mozprofile.XaA5YbSD8jeh, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0.3, platformVersion=10.0, moz:processID=7440, browserName=firefox, platformName=windows_nt}]
Session ID: 1ad0b6c1-bb5c-4306-afa6-b4e3dcb62ac1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325)
at testcases.Base.beforeTest(Base.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.TestRunner.beforeRun(TestRunner.java:626)
at org.testng.TestRunner.run(TestRunner.java:594)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
I have seemed to have resolved this issue, Looked like there was some compatibility issues. Now I am using the following configurations
selenium 3.4
Firefox browser v48
geckodriver 17

All test Fails automatically after first #Test failure from same class

I use TestNG + Selenium + Appium.
Problem which i have is:
If the 1st #Test fails, all rest got failed automatically and execution will be stopped.
I tried to use #BecoreClass setUp instead of setting up at #Test still after first failure fails everything.
I thought that it skipping all the rest of the test because of it does not finish the process in the right way ( quitting an application ) that`s why i added #Aftermethod with driver.quit that it will execute it after failed method.
But still after 1st failure it automatically Fails all the tests.
I need to have multiple #Test with a test methods, which will be individual with separate configurations. And if 1st one fails, it will continue execute the rest of #Test ( even if they are from the same class) and after will give me a result .
package foundation;
import com.pageobjects.HeaderMenu;
import config.AppConfiguration;
import config.LogIn;
import config.DesiredCapabilitiesSetup;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.*;
import org.testng.asserts.SoftAssert;
import java.io.IOException;
public class AppiumTestTest {
private AndroidDriver<AndroidElement> driver;
private AOWebClient aoWeb;
#SuppressWarnings("unused")
public AppiumTestTest(AndroidDriver<AndroidElement> driver, AOWebClient aoWeb) {
this.driver = driver;
this.aoWeb = aoWeb;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
#SuppressWarnings("unused")
public AppiumTestTest() {
}
private SoftAssert softAssert = new SoftAssert();
/*
#BeforeClass
public void setUp() throws Exception {
}
*/
#Test
public void checkInTest() throws Exception {
driver = DesiredCapabilitiesSetup.startAppiumServer(
AppConfiguration.newBuilder()
.setTimeSelection(false)
.setBirthday(true)
.build());
AOWebClient aoWebClient = DesiredCapabilitiesSetup.getAOWeb();
LogIn logIn = new LogIn(driver, aoWebClient);
logIn.logIn();
}
#Test
public void timeSelectionTest() throws Exception {
driver = DesiredCapabilitiesSetup.startAppiumServer(
AppConfiguration.newBuilder()
.setTimeSelection(true)
.setBirthday(true)
.build());
AOWebClient aoWebClient = DesiredCapabilitiesSetup.getAOWeb();
LogIn logIn = new LogIn(driver, aoWebClient);
logIn.logIn();
}
#AfterMethod
public void afterM(){
driver.close();
driver.quit();
}
}
My Desired Capabilities are:
package config;
import com.pageobjects.LaunchProgress;
import com.sun.javafx.tools.ant.DeployFXTask;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.json.simple.JSONObject;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class DesiredCapabilitiesSetup {
//Name of Android Device
//public static String deviceName = "TestDevice";
// Emulator
//public static String deviceName = "One";
//Path of App folder
// public static String appLink = "/Users/af185125/FoundationApp/";
//The name of Android application with format. (.apk).
//public static String appName = "app331.apk";
private static final String KEY_USE_TIME_SELECTION = "useTimeSelection";
private static final String KEY_DISABLE_BIRTHDAY = "disableBirthday";
#BeforeClass
public static AndroidDriver<AndroidElement> startAppiumServer(AppConfiguration appConfiguration) throws IOException {
// Taking App/Device/Link path from *txt file located in the project //
/*
String appLink = FileUtils.readFileToString(new File("appConfigurations/appLink.txt"));
String deviceName = FileUtils.readFileToString(new File("appConfigurations/deviceName.txt"));
String appName = FileUtils.readFileToString(new File("appConfigurations/appName.txt"));
*/
String appLink = FileUtils.readFileToString(new File("appConfigurations/appLink.txt"));
String deviceName = FileUtils.readFileToString(new File("appConfigurations/deviceName.txt"));
String appName = FileUtils.readFileToString(new File("appConfigurations/appName.txt"));
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
cap.setCapability(MobileCapabilityType.VERSION, "6.0");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "4000");
String configurationString = getConfigurationString(appConfiguration);
cap.setCapability(AndroidMobileCapabilityType.OPTIONAL_INTENT_ARGUMENTS,"--es appium_config \"" + configurationString + "\"");
//cap.setCapability("avd","nexus");
File appSource = new File(appLink);
File app = new File(appSource, appName);
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
LaunchProgress launch = new LaunchProgress(driver);
launch.waitForLaunchScreenToLoad();
return driver;
}
#SuppressWarnings("unchecked")
private static String getConfigurationString(AppConfiguration appConfiguration) {
JSONObject configuration = new JSONObject();
configuration.put(KEY_USE_TIME_SELECTION, appConfiguration.timeSelection);
configuration.put(KEY_DISABLE_BIRTHDAY, appConfiguration.birthday);
return configuration.toJSONString();
}
}
Stacktrace:
objc[20683]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Connected to the target VM, address: '127.0.0.1:58385', transport: 'socket'
[TestNG] Running:
/Users/af185125/Library/Caches/IdeaIC2016.2/temp-testng-customsuite.xml
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 80.28 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'WUSAF185125-G3D', ip: '153.86.242.30', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_91'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, appPackage=com.ao.demo.beta, networkConnectionEnabled=true, warnings={}, appWaitPackage=com.ao.demo.beta, appWaitActivity=com.ao.core.ui.launch.LaunchActivity, databaseEnabled=false, deviceName=ad071603280ea0c18d, version=6.0, fullReset=true, platform=LINUX, deviceUDID=ad071603280ea0c18d, appActivity=com.ao.core.ui.launch.LaunchActivity, desired={app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, newCommandTimeout=4000, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=Automation, version=6.0, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}", fullReset=true}, newCommandTimeout=4000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, platformName=Android, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}"}]
Session ID: 30270d0f-8594-4ead-b5b6-56dfeee37f44
*** Element info: {Using=id, value=fasf.com}
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:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:67)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:413)
at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:75)
at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:63)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at foundation.AppiumTestTest.checkInTest(AppiumTestTest.java:61)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:746)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
at org.testng.TestNG.runSuites(TestNG.java:1104)
at org.testng.TestNG.run(TestNG.java:1076)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 7 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'WUSAF185125-G3D', ip: '153.86.242.30', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_91'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, appPackage=com.ao.demo.beta, networkConnectionEnabled=true, warnings={}, appWaitPackage=com.ao.demo.beta, appWaitActivity=com.ao.core.ui.launch.LaunchActivity, databaseEnabled=false, deviceName=ad071603280ea0c18d, version=6.0, fullReset=true, platform=LINUX, deviceUDID=ad071603280ea0c18d, appActivity=com.ao.core.ui.launch.LaunchActivity, desired={app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, newCommandTimeout=4000, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=Automation, version=6.0, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}", fullReset=true}, newCommandTimeout=4000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, platformName=Android, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}"}]
Session ID: 30270d0f-8594-4ead-b5b6-56dfeee37f44
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:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:268)
at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:521)
at foundation.AppiumTestTest.afterM(AppiumTestTest.java:46)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:712)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:746)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
at org.testng.TestNG.runSuites(TestNG.java:1104)
at org.testng.TestNG.run(TestNG.java:1076)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
Test ignored.
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 5 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'WUSAF185125-G3D', ip: '153.86.242.30', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_91'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, appPackage=com.ao.demo.beta, networkConnectionEnabled=true, warnings={}, appWaitPackage=com.ao.demo.beta, appWaitActivity=com.ao.core.ui.launch.LaunchActivity, databaseEnabled=false, deviceName=ad071603280ea0c18d, version=6.0, fullReset=true, platform=LINUX, deviceUDID=ad071603280ea0c18d, appActivity=com.ao.core.ui.launch.LaunchActivity, desired={app=/Users/af185125/android-ui-test/currentApp/appiumT.apk, newCommandTimeout=4000, platformVersion=6.0, automationName=Appium, platformName=Android, deviceName=Automation, version=6.0, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}", fullReset=true}, newCommandTimeout=4000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, platformName=Android, optionalIntentArguments=--es appium_config "{"useTimeSelection":false,"disableBirthday":true}"}]
Session ID: 30270d0f-8594-4ead-b5b6-56dfeee37f44
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:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:268)
at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:521)
at foundation.AppiumTestTest.afterM(AppiumTestTest.java:46)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:712)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1129)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:746)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1189)
at org.testng.TestNG.runSuites(TestNG.java:1104)
at org.testng.TestNG.run(TestNG.java:1076)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
Move driver = DesiredCapabilitiesSetup.startAppiumServer... to #BeforeMethod. Also if you want to use different drivers for tests you will have to add parametrization (e.g. #BeforeMethod for group, #DataProvider or #Facotry).

Categories