Невозможно найти элемент в Selenium Appium с эмулятором Android - PullRequest
0 голосов
/ 05 октября 2018

TestBase.java ::

public class TestBase 

{   
public static final Logger log = Logger.getLogger(TestBase.class.getName());

public static AndroidDriver<AndroidElement> driver ;

 protected String url = "XXXXX";

  public  void init() throws MalformedURLException {

DesiredCapabilities capabilities  = new DesiredCapabilities();

capabilities .setCapability(MobileCapabilityType.DEVICE_NAME,         
"XXXX_Emulator");

capabilities .setCapability(MobileCapabilityType.BROWSER_NAME,"Chrome");

driver = new AndroidDriver<AndroidElement>(new 

URL("http://127.0.0.1:4723/wd/hub"),capabilities);

driver.navigate().to(url);

}
}

Telephones.java ::

public class Telephones extends TestBase

{


public static final Logger log Logger.getLogger(Telephones.class.getName());

AndroidDriver<AndroidElement> driver;

public Telephones(AndroidDriver<AndroidElement> driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}  



@AndroidFindBy(xpath="//div[@id='XXX_cookie_content_wrapper']//android.widget.button[@name='cookies-accepteren']")

//  @AndroidFindBy(xpath="//android.widget.div[@resource-id='XXX_cookie_content_wrapper']//android.widget.button[@name='cookies-accepteren']")

//  @AndroidFindBy(xpath="//android.widget.TextView[@text='Wil je onze optimale cookies accepteren']")
    WebElement Cookies_Acceptance;

//Accepting Cookes  

    public void Cookies_Acceptance() throws InterruptedException

    {

        Actions action = new Actions(driver);

        action.moveToElement(Cookies_Acceptance).click().build().perform();

            //Accepting Cookies to proceed

//      Cookies_Acceptance.click();

        log.info("Accepted Cookies");

    }

TC001_phones_VerifyiProductBuying ::

public class TC001_phones_VerifyiProductBuying extends TestBase {

public static final Logger log = Logger.getLogger(TC001_phones_VerifyiProductBuying.class.getName());


    @BeforeClass

    public void setUp() throws MalformedURLException{

        //calling init function from testbase class

        init();

        }       

    @Test

    public void Telefoons_VerifyProductBuying() throws InterruptedException {

    //creating object to Telephones class to use methods in that class

        Telephones telephones = new Telephones(driver);

            log.info("=========== Started Telefoons VerifyiProductBuying Test 
=============");

    //Calling Methods from telephones class

telephones.Cookies_Acceptance();

}

Ошибка консоли:

System info: host: 'INHYDKRLSOWMYA', ip: '192.168.24.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.json.BeanToJsonConverter.convertUsingMethod(BeanToJsonConverter.java:195)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$new$11(BeanToJsonConverter.java:90)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$convertObject$26(BeanToJsonConverter.java:171)
    at java.util.Optional.map(Optional.java:215)
    at org.openqa.selenium.json.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:171)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$null$16(BeanToJsonConverter.java:102)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$new$18(BeanToJsonConverter.java:103)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$convertObject$26(BeanToJsonConverter.java:171)
    at java.util.Optional.map(Optional.java:215)
    at org.openqa.selenium.json.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:171)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$null$19(BeanToJsonConverter.java:109)
    at com.google.common.collect.SingletonImmutableBiMap.forEach(SingletonImmutableBiMap.java:65)
    at org.openqa.selenium.json.BeanToJsonConverter.lambda$new$20(Bea
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"*[name='Cookies_Acceptance']"}
  (Session info: chrome=69.0.3497.100)
  (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.16299 x86_64)
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'INHYDKRLSOWMYA', ip: '192.168.24.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {browserName: Chrome, databaseEnabled: false, desired: {browserName: Chrome, deviceName: XXX_Emulator, platformName: android}, deviceManufacturer: Google, deviceModel: Android SDK built for x86, deviceName: emulator-5554, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: LINUX, platformVersion: 8.1.0, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 1f723269-4c54-4aa6-b751-ce46bfe6fdc7

Appium Журналы в командной строке:

Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"*[name='Cookies_Acceptance']"}
  (Session info: chrome=69.0.3497.100)
  (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.16299 x86_64)
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'INHYDKRLSOWMYA', ip: '192.168.24.10', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {browserName: Chrome, databaseEnabled: false, desired: {browserName: Chrome, deviceName: XXX_Emulator, platformName: android}, deviceManufacturer: Google, deviceModel: Android SDK built for x86, deviceName: emulator-5554, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: LINUX, platformVersion: 8.1.0, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 1f723269-4c54-4aa6-b751-ce46bfe6fdc7
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...