我正在使用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浏览器自动执行此方案。
答案 0 :(得分:0)
最后我找到了这个问题的答案。我使用了android chrome browser widget的xpath作为元素。这是错误的,修复是我必须使用桌面浏览器的xpath作为以下内容。
@FindBy(xpath = "//input[@name='fname']") WebElement FIRST_NAME_TEXT_BOX;