Running Selenium webdriver scripts in android device (Samasung galaxy tab)-Portrait mode

296 views
Skip to first unread message

Rashmi murthy

unread,
Nov 22, 2013, 4:35:49 AM11/22/13
to seleniu...@googlegroups.com
Hi,

I have been stuck in an issue while running selenium webdriver java script in android device -Portrait mode.
Script is running successfully in landscape mode but when we run the same script in android device keeping device in portrait mode script is failing for few actions 
like clicking the link ,even though object locator remains same. 

Script is like below,
 @Test
  public void testUntitled() throws Exception {
    driver.get("<application uRl>");
    driver.findElement(By.xpath("//ul[2]/li[2]/a/div")).click();
    driver.findElement(By.cssSelector("<css selector>")).click();
  }

  Note: First two statements are passing in portrait mode , 
  This statements "driver.findElement(By.cssSelector("<css selector>")).click();" fails in portrait mode by throwing exception like below


org.openqa.selenium.ElementNotVisibleException: This WebElement is not visisble and may not be clicked.
Build info: version: &apos;unknown&apos;, revision: &apos;unknown&apos;, time: &apos;unknown&apos;
System info: os.name: &apos;Linux&apos;, os.arch: &apos;armv7l&apos;, os.version: &apos;2.6.36.3&apos;, java.version: &apos;0&apos;
Driver info: driver.version: unknown
Command duration or timeout: 322 milliseconds
Build info: version: &apos;2.32.0&apos;, revision: &apos;6c40c18&apos;, time: &apos;2013-04-09 17:22:56&apos;
System info: os.name: &apos;Windows 7&apos;, os.arch: &apos;x86&apos;, os.version: &apos;6.1&apos;, java.version: &apos;1.7.0_40&apos;
Session ID: 1385108177533
Driver info: org.openqa.selenium.android.AndroidDriver
Capabilities [{platform=ANDROID, acceptSslCerts=true, javascriptEnabled=true, handlesAlerts=true, browserName=android, browserConnectionEnabled=true, webStorageEnabled=true, rotatable=true, locationContextEnabled=true, applicationCacheEnabled=true, webdriver.remote.sessionid=1385108177533, takesScreenshot=true, version=13}]


Please suggest how this issue can be resolved. Is there any settings to be done for running script in portrait mode?

Thanks in advance!!

Ben White

unread,
Nov 22, 2013, 3:37:38 PM11/22/13
to seleniu...@googlegroups.com
Sounds like the element you are trying to click is not visible. This is most likely caused by the element being outside the viewport. Unlike the firefox driver, the android driver will not scroll to an element to click on it. By scrolling up/down or left/right until the element is visible you should be able to find the element.

I haven't tested it out in Android in a while, but the following should allow you to scroll to the bottom of a page in python (I don't know the java equivalent):
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

Rashmi murthy

unread,
Nov 24, 2013, 11:44:51 PM11/24/13
to seleniu...@googlegroups.com
Hi Ben White,

Thanks for the reply!!


But the element what I am trying to click is with in the view point only(top of the screen->header section). Same element works in landscape mode of android device. But in portrait mode it is failing though in portrait mode locator remains same.

Could you please suggest solution for this if u have any idea about this kind of issue..

ilay

unread,
Jun 5, 2015, 7:43:38 PM6/5/15
to seleniu...@googlegroups.com
Hi,

Can you tell me, how you made firefox driver to work in android.?.
I want to test firefox browser in android device, i need to get firefox driver object,
I am using the following code,

DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setCapability("Browser", "firefox"); capability.setCapability(CapabilityType.BROWSER_NAME, "firefox");
wd = new RemoteWebDriver(u, capability);


 but i am getting error always.Can you please help me. Following is the error,

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' System info: host: 'hdc2-d-7tfs4p1.gdnindia.com', ip: '10.211.166.253', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_65' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593) – 
Caused by: org.apache.http.NoHttpResponseException: 192.168.2.23:8080 failed to respond at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpRespons‌ ​eParser.java:143) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpRespons‌ ​eParser.java:57) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:2‌ ​60) at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultB‌ ​HttpClientConnection.java:161)at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:153)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecut‌ ​or.java:271) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:12‌ ​3) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java‌ ​:184) at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java‌ ​:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java‌ ​:57) at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpC‌ ​lient.java:144) at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.ja‌ ​va:72) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:‌ ​133) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572) ...

Krishnan Mahadevan

unread,
Jun 5, 2015, 11:22:22 PM6/5/15
to Selenium Users
I think you need to basically consider Firefox as yet another app on Android and then work with it. By default a web application to be loaded on an android/ios device/simulator is always going to make Appium/Selendroid/ios-Driver look for the default browser on the platform.

Any other browser would have to be treated as if it were an application.

Atleast this is what I know based on my limited explorations.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/9a3d686b-c13a-469b-a6df-1dbef74b4f63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ilay

unread,
Jun 9, 2015, 12:55:13 AM6/9/15
to seleniu...@googlegroups.com
Hi Krishnan Mahadevan,

What you said is correct, I am treating firefox as an separate App. But, the issue is, whenever i try to get the firefox driver object like i posted in the trail mail, it is throwing the following error,

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

I don't know the source of this error.
Or is there any other way to open a firefox browser using driver and i need to return the driver object.

I am successful in opening the Chrome browser in android device by running the chrome driver on Mac(Chrome driver latest (2.15) has that functionality).
But for firefox, we dont have separate driver like chrome, opera..

Please guide me here, what can i do for firefox.

Thanks & Regards,
Ilay.

Krishnan Mahadevan

unread,
Jun 9, 2015, 3:11:07 AM6/9/15
to Selenium Users
Ilay

The code snippet that you shared for firefox is basically going to try to open up the firefox browser directly [ as how it would on a desktop ]. Your code doesn't seem to be having anything that basically is treating firefox as an app [ You can refer here to understand how it should work : http://selendroid.io/setup.html#getAut ]




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

ilay

unread,
Jun 10, 2015, 3:58:08 AM6/10/15
to seleniu...@googlegroups.com
Krishnan,

I tried with Selendroid, by following your link, 
i executed the following command in terminal,

java -jar documents/adse_pixel/supporting_jars/selendroid-standalone-0.15.0-with-dependencies.jar -app /Applications/Softwares/android-sdk-macosx/platform-tools/org.mozilla.firefox-2.apk


Selendroid Server has started successfully in port 4444

INFO: Selendroid standalone server has been started on port: 4444 

but, after that when i execute the following lines in eclipse,

SelendroidCapabilities capa = SelendroidCapabilities.device("org.mozilla.firefox:34.0");

wd = new SelendroidDriver(capa);


i got the following messages running in terminal,

Jun 10, 2015 1:18:51 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Checking if the Selendroid server is running: http://localhost:8083/wd/hub/status
Jun 10, 2015 1:18:51 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8083: The target server failed to respond
Jun 10, 2015 1:18:51 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:8083
Jun 10, 2015 1:18:51 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8083: The target server failed to respond
Jun 10, 2015 1:18:51 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:8083
Jun 10, 2015 1:18:51 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8083: The target server failed to respond
Jun 10, 2015 1:18:51 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:8083
Jun 10, 2015 1:18:51 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Can't connect to Selendroid server, assuming it is not running.


Seems like, my android device(Samsung S3, Model:GT-I9300, Android Version: 4.1.2) is not responding.
It is the simillar error that i got with last approach also.
So, what will be the problem for this.
Can you please help me here.

Thanks & Regards,
Ilay.

ilay

unread,
Jun 16, 2015, 8:23:02 AM6/16/15
to seleniu...@googlegroups.com
Anybody, tell me an way to open firefox and opera browsers in an android device and i have to get driver object for that browser, with the driver object I need to perform several actions on the webpage like, open the URL, getting element locations/positions, clicking the object, verifying the object attributes, etc., I am unsuccessful in using with "RemoteWebDriver" and "Selendroid Driver", so please give me some idea/approach to do it.

Regards,
Ilay.
Reply all
Reply to author
Forward
0 new messages