Able to locate the element but unable to click on it

365 views
Skip to first unread message

Sasi Pavan

unread,
Sep 3, 2014, 7:25:42 AM9/3/14
to appium-...@googlegroups.com
Hi All,

We are currently working on automating mobile web using appium, we are able to identify the object but unable to click the element object . PFB code

                 waitForElementToBeClickable(By.xpath("//*[@id='swipeview-masterpage-2']"), 180, "wait till Instock view is selected");
boolean Instock=driver.findElement(By.xpath("//*[@id='swipeview-masterpage-2']/span")).isDisplayed();
System.out.println(Instock);

System.out.println(driver.findElement(By.xpath("//*[@id='swipeview-masterpage-2']/span")).getText());

                driver.findElement(By.xpath("//*[@id='swipeview-masterpage-2']/span")).click();

String varInstock=driver.findElement(By.xpath("//*[@id='swipeview-masterpage-2']/span")).getAttribute("class");
System.out.println("Instock view:"+varInstock);

                Assert.assertTrue("will verify whether class of instock has been changed to selected after tapping on instock", varInstock.equals("selected"));

Above code is working in local browser and sauce labs andriod emulator, however it is not working in real device and local emulator. After clicking instock element, class of object will be changing from blank to selected
We are getting assertion error as varInstock value is blank, as we are unable to click on Instock element.

Console Output:
true
In-stock
Instock view:

PFB for the source code:

Before selection of instock

<div id="swipeview-slider" style="position: relative; top: 0px; height: 100%; width: 100%; transform: translate3d(0px, 0px, 0px); transition-timing-function: ease-out;">
<div id="swipeview-masterpage-0" style="transform: translateZ(0px); position: absolute; top: 0px; height: 100%; width: 33.3333%; left: 0%;"/>
<div id="swipeview-masterpage-1" style="transform: translateZ(0px); position: absolute; top: 0px; height: 100%; width: 33.3333%; left: 33.3333%;">
<span class="selected">All Products</span>
</div>
<div id="swipeview-masterpage-2" style="transform: translateZ(0px); position: absolute; top: 0px; height: 100%; width: 33.3333%; left: 66.6667%;">
<span>In-Stock</span>
</div>
</div>

After selection of Instock

<div id="swipeview-slider" style="position: relative; top: 0px; height: 100%; width: 100%; transform: translate3d(0px, 0px, 0px); transition-timing-function: ease-out;">
<div id="swipeview-masterpage-0" style="transform: translateZ(0px); position: absolute; top: 0px; height: 100%; width: 33.3333%; left: 66.6667%;"/>
<div id="swipeview-masterpage-1" style="transform: translateZ(0px); position: absolute; top: 0px; height: 100%; width: 33.3333%; left: 0px;">
<div id="swipeview-masterpage-2" style="transform: translateZ(0px); position: absolute; top: 0px; height: 100%; width: 33.3333%; left: 33.3333%;">
<span class="selected">In-Stock</span>
</div>
</div>

PFA for appium log

AppiumLog.txt
Reply all
Reply to author
Forward
0 new messages