0

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);

}
}

电话.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();

}

控制台错误:

系统信息:主机:'INHYDKRLSWMYA',ip:'192.168.24.10',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_172 '
驱动程序信息:driver.version:RemoteWebDriver
    在 org.openqa.selenium.json.BeanToJsonConverter.convertUsingMethod(BeanToJsonConverter.java:195)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$new$11(BeanToJsonConverter.java:90)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$convertObject$26(BeanToJsonConverter.java:171)
    在 java.util.Optional.map(Optional.java:215)
    在 org.openqa.selenium.json.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:171)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$null$16(BeanToJsonConverter.java:102)
    在 java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    在 java.util.Iterator.forEachRemaining(Iterator.java:116)
    在 java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    在 java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    在 java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    在 java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    在 java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    在 java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$new$18(BeanToJsonConverter.java:103)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$convertObject$26(BeanToJsonConverter.java:171)
    在 java.util.Optional.map(Optional.java:215)
    在 org.openqa.selenium.json.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:171)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$null$19(BeanToJsonConverter.java:109)
    在 com.google.common.collect.SingletonImmutableBiMap.forEach(SingletonImmutableBiMap.java:65)
    在 org.openqa.selenium.json.BeanToJsonConverter.lambda$new$20(Bea
引起:org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:{“method”:“css selector”,“selector”:“* [name ='Cookies_Acceptance']”}
  (会话信息:chrome=69.0.3497.100)
  (驱动程序信息:chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),平台=Windows NT 10.0.16299 x86_64)
有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html
构建信息:版本:'3.12.0',修订:'7c6e0b3',时间:'2018-05-08T14:04:26.12Z'
系统信息:主机:'INHYDKRLSWMYA',ip:'192.168.24.10',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_172 '
驱动信息:io.appium.java_client.android.AndroidDriver
功能 {browserName:Chrome,databaseEnabled:false,期望:{browserName:Chrome,deviceName:XXX_Emulator,platformName:android},deviceManufacturer:Google,deviceModel:为 x86 构建的 Android SDK,deviceName:emulator-5554,deviceScreenSize:1080x1920,deviceUDID: emulator-5554,javascriptEnabled:true,locationContextEnabled:false,networkConnectionEnabled:true,平台:LINUX,platformName:LINUX,platformVersion:8.1.0,takeScreenshot:true,警告:{},webStorageEnabled:false}
会话 ID:1f723269-4c54-4aa6-b751-ce46bfe6fdc7

Appium 在命令提示符下登录:

引起:org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:{“method”:“css selector”,“selector”:“* [name ='Cookies_Acceptance']”}
  (会话信息:chrome=69.0.3497.100)
  (驱动程序信息:chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),平台=Windows NT 10.0.16299 x86_64)
有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html
构建信息:版本:'3.12.0',修订:'7c6e0b3',时间:'2018-05-08T14:04:26.12Z'
系统信息:主机:'INHYDKRLSWMYA',ip:'192.168.24.10',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_172 '
驱动信息:io.appium.java_client.android.AndroidDriver
功能 {browserName:Chrome,databaseEnabled:false,期望:{browserName:Chrome,deviceName:XXX_Emulator,platformName:android},deviceManufacturer:Google,deviceModel:为 x86 构建的 Android SDK,deviceName:emulator-5554,deviceScreenSize:1080x1920,deviceUDID: emulator-5554,javascriptEnabled:true,locationContextEnabled:false,networkConnectionEnabled:true,平台:LINUX,platformName:LINUX,platformVersion:8.1.0,takeScreenshot:true,警告:{},webStorageEnabled:false}
会话 ID:1f723269-4c54-4aa6-b751-ce46bfe6fdc7
4

0 回答 0