XCTest。检测访问库警报视图

时间:2015-10-08 14:41:55

标签: ios swift2 uialertview ios-ui-automation xctest

我在检测UIAlertView时遇到问题,当我不想在UI XCTest中从照片库中获取照片时出现。我的代码:

let app = XCUIApplication()
let alertView = app.alerts["\u{201c}MyAppName\u{201d} Would Like to Access Your Photos"]

警报视图已在屏幕上,但在alertView我没有。有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

警报视图值中的某些章程可能会错过。

使用index而不是String Value。

 app.alerts.elementBoundByIndex(0).buttons["OK"].tap()

以及tap alertButton

的示例
--Bulk insert first 30 lines of the finalreport.txt file into dbo.tmp_finalreportheader

    SET @bulkCommand = ' BULK INSERT ' + DB_NAME() + '.dbo.tmp_finalreportheader
    FROM ''' + @fileName + '''
    WITH (ROWTERMINATOR = ''\n'',
          FIELDTERMINATOR = ''\t'',
          DATAFILETYPE = ''char'',
          MAXERRORS = 0,
          FIRSTROW = 1,
          LASTROW = 30)'
    EXEC(@bulkCommand)

    ALTER TABLE dbo.tmp_finalreportheader
    ADD lineId INT IDENTITY(1,1)

    PRINT 'dbo.tmp_finalreportheader table created'

/**************************************************************************************************************
Select the string from row n where the column headers are i.e. Name, ID...
Using function dbo.BreakStringIntoRowsTab
(where line = [DATA] + 1)
**************************************************************************************************************/

    DECLARE @RowNumber INT = (SELECT lineId + 1 FROM dbo.tmp_finalreportheader WHERE line='[DATA]');
    DECLARE @Data INT=(SELECT lineId + 2 FROM dbo.tmp_finalreportheader WHERE line='[DATA]');

    SET @myString=(SELECT line FROM dbo.tmp_finalreportheader WHERE lineId=@RowNumber)

    IF OBJECT_ID('tempdb..#tmpHead') IS NOT NULL DROP TABLE #tmpHead

    SELECT *
    INTO #tmpHead
    FROM dbo.BreakStringIntoRows(@myString);

    SELECT @sqlColumns = COALESCE(@sqlColumns + ', ', '') + '[' + Headers + '] NVARCHAR(100)' FROM #tmpHead;

    SELECT @sql = 'CREATE TABLE tmp_Import (' + @sqlColumns + ')';

    EXEC sp_executesql @sql

它对我有用