目前,我正在使用WebDriverWait(XCUITest
)等待在iOS应用上显示元素。
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("priority 1 program")));
这适用于本地计算机,但不适用于Bitrise服务器。
使用Bitrise的日志,我意识到Appium确实返回了元素(已找到)但未在屏幕上显示(isDisplay
返回false
)。
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["name","priority 1 program","7b75a5af-448a-4d48-9187-3bbb84aa5519"]
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/103F53F0-47D8-4604-8CB7-8AB5794DDD9F/element] with body: {"using":"name","value":"priority 1 program"}
[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"F30723B8-E7B0-4299-B260-AE3455918DBF"},"sessionId":"103F53F0-47D8-4604-8CB7-8AB5794DDD9F","status":0}
[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"F30723B8-E7B0-4299-B260-AE3455918DBF"}
[HTTP] <-- POST /wd/hub/session/7b75a5af-448a-4d48-9187-3bbb84aa5519/element 200 2540 ms - 122
[HTTP] --> GET /wd/hub/session/7b75a5af-448a-4d48-9187-3bbb84aa5519/element/F30723B8-E7B0-4299-B260-AE3455918DBF/displayed {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [XCUITest] Executing command 'proxyReqRes'
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/7b75a5af-448a-4d48-9187-3bbb84aa5519/element/F30723B8-E7B0-4299-B260-AE3455918DBF/displayed] to [GET http://localhost:8100/session/103F53F0-47D8-4604-8CB7-8AB5794DDD9F/element/F30723B8-E7B0-4299-B260-AE3455918DBF/displayed] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\n \"value\" : false,\n \"sessionId\" : \"103F53F0-47D8-4604-8CB7-8AB5794DDD9F\",\n \"status\" : 0\n}"
所以我检查了屏幕截图,令人惊讶的是显示的元素没有任何重叠的视图。
我已尝试过不同类型的环境,但情况相同。
我也从互联网上进行了一些搜索,但似乎没有解决方案可行。
https://github.com/appium/appium/issues/9377
https://github.com/facebook/WebDriverAgent/issues/746
https://github.com/appium/appium/issues/4131
感谢任何帮助,谢谢。
答案 0 :(得分:0)
有几个与元素可见性相关的未解决的问题,它可能与 WebDriverAgent 中的issue或您提到的那个相关,但仍未修复。
作为一种解决方法,您可以:
import { Component, OnInit } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {alarm} from "../shared/alarm.model";
import { DataTableResource } from 'angular-4-data-table';
@Component({
selector: 'app-alarm-data-table',
providers:[],
templateUrl: './alarm-data-table.component.html',
styleUrls: ['./alarm-data-table.component.css']
})
export class AlarmDataTableComponent implements OnInit {
alarmsData = new DataTableResource(this.alarmsData);
alarmCount:number =0;
constructor( private http: HttpClient) {
}
ngOnInit() {
this.http.get<alarm[]>('http:my api ').
subscribe(data => {this.alarmsData = data ; this.alarmCount =data.length ;}
, error2 => {console.log('Error has occured');
});
}
}
并且基本上只等到元素存在,跳过 </data-table-column>
<data-table-column
[property]="'naturalId'"
[header]="'Natural'"
[sortable]="true"
[resizable]="true">
</data-table-column>
</data-table>
</div>
属性