arc_util.py: Fix the detection of termsPage loaded

To align with the javascript code in Chrome side, the patch fixes
the detection of terms Page loaded accordingly.

BUG=chromium:664869
TEST=on minnie, the opt-in test passes.

Change-Id: Iaebd2c29e0f01a826e14fc1740fc17bc08bb7d7c
Signed-off-by: Chung-yih Wang <cywang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/410965
Reviewed-by: Hsu-Cheng Tsai <hctsai@chromium.org>
diff --git a/client/common_lib/cros/arc_util.py b/client/common_lib/cros/arc_util.py
index 63fcc6e..6cf4e98 100644
--- a/client/common_lib/cros/arc_util.py
+++ b/client/common_lib/cros/arc_util.py
@@ -209,9 +209,8 @@
         raise error.TestError('Found opt-in extension but not correct page!')
     extension_main_page.WaitForDocumentReadyStateToBeComplete()
 
-    js_code_terms = 'appWindow.contentWindow.document.getElementById(\'terms\')'
-    js_code_did_start_conditions = [
-            'appWindow', js_code_terms, '!%s.hidden' % js_code_terms]
+    js_code_did_start_conditions = ['termsPage != null',
+            'termsPage.state_ == LoadState.LOADED']
     try:
         for condition in js_code_did_start_conditions:
             extension_main_page.WaitForJavaScriptExpression(condition, 60.0)