繁体   English   中英

使用Appium和Java进行移动测试自动化时,不会发生此类元素问题

[英]No such element issue occurring on mobile test automation using Appium and Java

我正在使用Appium和Selenium自动执行此注册页面https://www.gridlastic.com/register.php

public class GridlasticRegistrationPage extends BasePage {

@FindBy(xpath = "//android.widget.EditText[@text='First Name']") WebElement FIRST_NAME_TEXT_BOX;
@FindBy(xpath = "//android.widget.EditText[@text='Last Name']") WebElement LAST_NAME_TEXT_BOX;


public void navigateToGridlasticRegistrationPage(){
    driver.get("https://www.gridlastic.com/register.php");
}


public void register(String fName, String lName){
    waitForElement(FIRST_NAME_TEXT_BOX);
    FIRST_NAME_TEXT_BOX.sendKeys(fName);
    waitForElement(LAST_NAME_TEXT_BOX);
    LAST_NAME_TEXT_BOX.sendKeys(lName);
   GET_FREE_ACCOUNT_BUTTON.click();
  }

}

但是在这段代码中,我得到以下错误。

    Failed Step: Register to Gridlastic using First Name, Last Name, Comapany, Work Email, Username and Password in the following table <table:/resources/gridlastic_registration_details.csv>
    Specification: specs\GridlasticRegistration.spec:16
    Error Message: org.openqa.selenium.TimeoutException: Timed out after 15 seconds waiting for element to be clickable: Proxy element for: org.openqa.selenium.support.pagefactory.DefaultElementLocator@fae9e82
    Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
    System info: host: 'Mitrai-OsandaN', ip: '192.168.88.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
    Driver info: io.appium.java_client.android.AndroidDriver
    Capabilities [{deviceScreenSize=768x1280, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, version=5.1.0, deviceName=192.168.88.101:5555, platform=ANDROID, deviceUDID=192.168.88.101:5555, desired={browserName=chrome, platformName=Android, version=5.1.0, deviceName=My phone, platform=ANDROID}, platformVersion=5.1, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, browserName=chrome, javascriptEnabled=true, deviceModel=Custom Phone - 5.1.0 - API 22 - 768x1280, platformName=Android, deviceManufacturer=unknown}]
    Session ID: 4ec65f50-9746-4093-ae33-f0d1f735652f
    Stacktrace: 
    org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80)
    org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:229)

请帮我解决这个问题。 即使删除“ WebDriverWait等待”,它也会显示“没有这样的元素”。 我认为问题出在xpath中。 但是我尝试了许多xpath,仍然得到相同的错误。

请注意,我正在使用android chrome浏览器自动执行此方案。

最后,我找到了解决该问题的方法。 我使用android chrome浏览器小部件的xpath作为元素。 这是错误的,解决方法是我必须使用台式机浏览器的xpath如下。

 @FindBy(xpath = "//input[@name='fname']") WebElement FIRST_NAME_TEXT_BOX;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM