@AndroidFindBy在使用appiumDriver时不工作

ih99xse1  于 2023-04-18  发布在  Android
关注(0)|答案(1)|浏览(65)

我想使用AndroidAndroidFindBy和iOSXCUITAndroidFindBy,但无法正常工作。
错误代码:
org.openqa.selenium.InvalidSelectorException:不支持的CSS选择器“*[name ='introStartButton']”。原因:“错误:“name”不是有效的属性。支持的属性为“checkable”、“checked”、“clickable”、“enabled”、“focusable”、“focused”、“long-clickable”、“scrollable”、“selected”、“index”、“instance”、“description”、“resource-id”、“text”、“class-name”、“package-name”
我的代码在这里:

package commonSteps.Auth;

import Helpers.Config; 
import Helpers.Utils;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.qameta.allure.Step;
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;

import java.util.Objects;

public class simpleClass {
 
    //locators
    @iOSXCUITAndroidFindBy(accessibility = "button_login")
    @AndroidFindBy(id = "introStartButton")
    WebElement loginLocator;

 

    // Creating a variable called driver that is of type WebDriver.
    public AppiumDriver driver;
 

    // This is a constructor. It is called when an object of the class is created.
    public simpleClass(AppiumDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);
  
 }

 
    @Test(description = "example")
    public void simpleTest() throws InterruptedException {
    loginLocator.click();
   }
 

}
p1tboqfb

p1tboqfb1#

错误消息你有共享状态,你试图使用css选择器名称.但名称不是一个有效的css选择器.有效的Css选择器是类和id.在代码中,你提到的代码片段id=introStartButton你能分享完整的代码,我试图在我的本地机器上执行?

相关问题