「title_I_need」というタイトルのボタンが存在するかどうかを確認する必要があります。存在する場合はそれを押して、そうでない場合は別のものを押します。これらはすべて JavaScript で書かれています。
Appium.App テストに記録し、ボタンが存在する場合は検証を追加しました。私は JavaScript にあまり詳しくないので、Objective-C から始めました。しかし、結果として、常に title_I_need ボタンをクリックしますが、私の期待は、other_title ボタンによる else ブランチです。
Appiumでそのようなチェックを行うことはできますか? はいの場合、JavaScript (node.js) でこれを行うにはどうすればよいですか?
#import <Selenium/SERemoteWebDriver.h>
@implementation SeleniumTest
-(void) run
{
SECapabilities *caps = [SECapabilities new];
[caps addCapabilityForKey:@"appium-version" andValue:@"1.0"];
[caps setPlatformName:@"iOS"];
[caps setPlatformVersion:@"8.4"];
[caps setDeviceName:@"device_name"];
[caps setApp:@"/path/AppName.app"];
NSError *error;
SERemoteWebDriver *wd = [[SERemoteWebDriver alloc] initWithServerAddress:@"0.0.0.0" port:4723 desiredCapabilities:caps requiredCapabilities:nil error:&error];
//check for element with wrong not existed title to go to else branch
if ([wd findElementBy:[SEBy name:@"wrong_title"]]){
[[wd findElementBy:[SEBy name:@"title_I_need"]] click];
} else {
[[wd findElementBy:[SEBy name:@"other_title"]] click];
}
}
@end