I have an android SDK and upon pressing a button opens a Webview where i can see a button whose html view is as below:
Now i'm trying to press/click a button using the following but nothing works :(
The above code doesn't throw any error and executes successfully but it doesn't click the button. Would appreciate if any espresso Webview expert can help me with clicking the button please. Thanks |
onWebView(withId(R.id.__sample_web_view)).forceJavascriptEnabled().withElement(findElement(Locator.ID, "submit-try-sample")).perform(webClick());
Logcat as follows:
07-11 02:05:48.867 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Forcibly enable javascript.' action on view WebView with JS enabled
07-11 02:06:30.375 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Forcibly enable javascript.' action on view with id: com.sample.android.sdk.sample:id/__sample_web_view
07-11 02:06:30.379 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.TransformingAtom@11d44f1 in window: null with element: null' action on view with id: com.sample.android.sdk.sample:id/__sample_web_view
07-11 02:06:30.400 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.webdriver.DriverAtoms$1@2077304 in window: null with element: {"ELEMENT":":wdc:1468217190399"}' action on view with id: com.sample.android.sdk.sample:id/__sample_web_view
07-11 02:06:30.437 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.sampleeAtom@b4f60ed in window: null with element: null' action on view WebView with JS enabled
07-11 02:06:30.455 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.sampleeAtom@4a2ab22 in window: null with element: null' action on view WebView with JS enabled
07-11 02:06:30.460 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.TransformingAtom@7b369b3 in window: null with element: null' action on view WebView with JS enabled
07-11 02:06:30.473 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performancerming 'Evaluate Atom: android.support.test.espresso.web.webdriver.DriverAtoms$1@50abb70 in window: null with element: {"ELEMENT":":wdc:1468217190400"}' action on view WebView with JS enabled
07-11 02:06:30.511 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.TransformingAtom@34e1ee9 in window: null with element: null' action on view WebView with JS enabled
07-11 02:06:30.527 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.webdriver.DriverAtoms$1@6e4576e in window: null with element: {"ELEMENT":":wdc:1468217190399"}' action on view WebView with JS enabled
07-11 02:06:30.557 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.sampleeAtom@3b81e9c in window: null with element: null' action on view WebView with JS enabled
07-11 02:06:30.602 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.model.TransformingAtom@c768888 in window: null with element: null' action on view WebView with JS enabled
07-11 02:06:30.611 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Evaluate Atom: android.support.test.espresso.web.webdriver.DriverAtoms$3@4abe646 in window: null with element: {"ELEMENT":":wdc:1468217190401"}' action on view WebView with JS enabled
07-11 02:06:30.629 5470-5470/com.sample.android.sdk.sample I/ViewInteraction: Performing 'Propagate: java.lang.RuntimeException: java.lang.RuntimeException: Error in evaluationEvaluation: status: 12 value: {message=Element is not currently interactable and may not be manipulated} hasMessage: true message: Element is not currently interactable and may not be manipulated' action on view WebView with JS enabled
07-11 02:06:30.631 5470-5519/com.sample.android.sdk.sample I/art: Starting a blocking GC Explicit
07-11 02:06:30.631 5470-5470/com.sample.android.sdk.sample D/LifecycleMonitor: Lifecycle status change: com.sample.android.sdk.sample.SampleActivity@a586f9c in: DESTROYED
07-11 02:06:30.637 5470-5519/com.sample.android.sdk.sample I/art: Explicit concurrent mark sweep GC freed 3499(268KB) AllocSpace objects, 20(1568KB) LOS objects, 39% free, 4MB/6MB, paused 184us total 5.881ms
07-11 02:06:30.637 5470-5519/com.sample.android.sdk.sample I/art: Starting a blocking GC Explicit
07-11 02:06:30.641 5470-5519/com.sample.android.sdk.sample I/art: Explicit concurrent mark sweep GC freed 236(31KB) AllocSpace objects, 1(24KB) LOS objects, 39% free, 4MB/6MB, paused 157us total 4.191ms
07-11 02:06:30.642 5470-5519/com.sample.android.sdk.sample I/TestRunner: failed: testShouldVerifyReminderAndActivitiesFlowForALead(com.sample.android.sdk.sample.Tests.FirstTransactionTest)
07-11 02:06:30.642 5470-5519/com.sample.android.sdk.sample I/TestRunner: ----- begin exception -----
07-11 02:06:30.643 5470-5519/com.sample.android.sdk.sample I/TestRunner: java.lang.RuntimeException: java.lang.RuntimeException: Error in evaluationEvaluation: status: 12 value: {message=Element is not currently interactable and may not be manipulated} hasMessage: true message: Element is not currently interactable and may not be manipulated
at android.support.test.espresso.web.sugar.Web$WebInteraction$ExceptionPropagator.<init>(Web.java:323)
at android.support.test.espresso.web.sugar.Web$WebInteraction.doEval(Web.java:292)
at android.support.test.espresso.web.sugar.Web$WebInteraction.perform(Web.java:259)
at com.sample.android.sdk.sample.screen.verifyOTPScreen.tapOnVerifyOTPButton(verifyOTPScreen.java:34)
at com.sample.android.sdk.sample.action.CheckoutAction.verifyUserIsAbleToMakeSuccessfulTransaction(CheckoutAction.java:31)
at com.sample.android.sdk.sample.Tests.FirstTransactionTest.testShouldVerifyReminderAndActivitiesFlowForALead(FirstTransactionTest.java:21)
at java.lang.reflect.Method.invoke(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at android.support.test.internal.runner.junit3.AndroidTestResult.runProtected(AndroidTestResult.java:77)
at junit.framework.TestResult.run(TestResult.java:118)
at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:55)
at junit.framework.TestCase.run(TestCase.java:124)
at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)
at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:69)
at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:103)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
Caused by: java.lang.RuntimeException: Error in evaluationEvaluation: status: 12 value: {message=Element is not currently interactable and may not be manipulated} hasMessage: true message: Element is not currently interactable and may not be manipulated
at android.support.test.espresso.web.model.sampleeAtom.handleBadEvaluation(sampleeAtom.java:142)
at android.support.test.espresso.web.model.sampleeAtom.transform(sampleeAtom.java:76)
at android.support.test.espresso.web.model.sampleeAtom.transform(sampleeAtom.java:30)
at android.support.test.espresso.web.action.AtomAction$2.apply(AtomAction.java:143)
at android.support.test.espresso.web.action.AtomAction$2.apply(AtomAction.java:140)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$2.apply(Futures.java:760)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:906)
at android.support.test.espresso.web.deps.guava.util.concurrent.MoreExecutors$DirectExecutor.execute(Mo
07-11 02:06:30.643 5470-5519/com.sample.android.sdk.sample I/TestRunner: ----- end exception -----
07-11 02:06:30.644 5470-5519/com.sample.android.sdk.sample I/TestRunner: finished: testShouldVerifyTransaction(com.sample.android.sdk.sample.Tests.FirstTransactionTest)
07-11 02:06:30.646 5470-5470/com.sample.android.sdk.sample I/MonitoringInstrumentation: Activities that are still in CREATED to STOPPED: 2
07-11 02:06:30.646 5470-5470/com.sample.android.sdk.sample I/MonitoringInstrumentation: Finishing activity: com.sample.android.sdk.view.activity.BasesampleScreen@c6f57c9
07-11 02:06:30.648 5470-5470/com.sample.android.sdk.sample I/MonitoringInstrumentation: Finishing activity: com.sample.android.sdk.sample.CheckoutActivity@444507d
07-11 02:06:30.648 5470-5470/com.sample.android.sdk.sample D/LifecycleMonitor: Lifecycle status change: com.sample.android.sdk.view.activity.BasesampleScreen@c6f57c9 in: PAUSED
07-11 02:06:30.649 5470-5519/com.sample.android.sdk.sample I/TestRunner: run finished: 1 tests, 1 failed, 0 ignored
07-11 02:06:30.653 5470-5470/com.sample.android.sdk.sample D/LifecycleMonitor: Lifecycle status change: com.sample.android.sdk.sample.CheckoutActivity@444507d in: DESTROYED
07-11 02:06:30.903 5470-5470/com.sample.android.sdk.sample D/LifecycleMonitor: Lifecycle status change: com.sample.android.sdk.view.activity.BasesampleScreen@c6f57c9 in: STOPPED
On Tue, Jul 12, 2016 at 12:04 AM, Nick Korostelev <nko
On Mon, Jul 11, 2016 at 2:18 AM, <keta...@gmail.com> wrote:The above code doesn't throw any error and executes successfully but it doesn't click the button.
I would try specifying the web view ID and forcing javascript: onWebView(withId(R.id.web_view)).forceJavascript().withElement(...)
Hi Nick / Luis,Thanks for replying!I've tried following statement as well but it fails with an exception mentioned the logcat detailsonWebView(withId(R.id.__sample_web_view)).forceJavascriptEnabled().withElement(findElement(Locator.ID, "submit-try-sample")).perform(webClick());
Hi Luis,I did not quite understand the first part. However i'm observing the same error as mentioned at https://github.com/googlesamples/android-testing/issues/61Any help would be really appreciated
<button type="button" class="button js-analytics-submit" id="submit-try-sample" data-analytics-category="Sample" data-analytics-label="Intro">
<svg xmlns="http://www.w3.org/2000/svg" width="58" height="58" viewBox="0 0 58 58" id="button-logo
" class="button__logo">
<path fill="currentColor" fill-rule="evenodd" d="M37.32 21.933l2.877-2.876-.626-.625c-5.04-5.043-13.247-5.043-18.29 0-4.832 4.833-5.03 12.568-.6 17.643l-2.876 2.875.625.625c5.042 5.043 13.247 5.043 18.29 0 4.832-4.832 5.03-12.567.6-17.642zm-14.79-2.25c4.144-4.144 10.76-4.344 15.142-.6l-1.64 1.64c-3.488-2.86-8.644-2.664-11.9.593-3.256 3.256-3.454 8.412-.594 11.9l-1.608 1.608c-3.743-4.382-3.542-11 .6-15.142zm12.94 18.642c-4.143 4.144-10.76 4.344-15.142.6l1.64-1.64c3.488 2.86 8.644 2.664 11.9-.593 3.256-3.256 3.454-8.412.594-11.9l1.608-1.608c3.743 4.382 3.543 10.998-.6 15.14z"></path>
</svg>
<span class="button__wrapper" id="button-text">
<span class="button__text">
Let’s do this!
</span>
</span>
</button>
<a href="google.com" id="anchor">Link!</a>
Can't get simpler than that. Then try clicking that link through Espresso. If that works, replace <a> with <button>. If that works, add the "class" attribute. If that works ... etc, etc. until you find the one change that makes it fail.-Mingxia