OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #import "ios/web_view/test/web_view_interaction_test_util.h" | |
6 | |
7 #import <ChromeWebView/ChromeWebView.h> | |
8 | |
9 #import "ios/testing/wait_util.h" | |
10 | |
11 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
12 #error "This file requires ARC support." | |
13 #endif | |
14 | |
15 namespace ios_web_view { | |
16 namespace test { | |
17 | |
18 bool TapChromeWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { | |
19 NSString* script = [NSString | |
20 stringWithFormat:@"(function() {" | |
Eugene But (OOO till 7-30)
2017/05/19 18:39:49
This script already exist somewhere else. Is there
michaeldo
2017/05/23 16:20:52
Unfortunately no at this point. But I will continu
| |
21 " var element = document.getElementById('%@');" | |
22 " if (element) {" | |
23 " element.click();" | |
24 " return true;" | |
25 " }" | |
26 " return false;" | |
27 "})();", | |
28 element_id]; | |
29 __block bool did_complete = false; | |
30 __block bool element_found = false; | |
31 [web_view evaluateJavaScript:script | |
32 completionHandler:^(id result, NSError*) { | |
33 did_complete = true; | |
34 element_found = [result boolValue]; | |
35 }]; | |
36 | |
37 testing::WaitUntilConditionOrTimeout(testing::kWaitForJSCompletionTimeout, ^{ | |
38 return did_complete; | |
39 }); | |
40 | |
41 return element_found; | |
42 } | |
43 | |
44 } // namespace test | |
45 } // namespace ios_web_view | |
OLD | NEW |