Not able to aut0mate on WebView

78 views
Skip to first unread message

sai krishna

unread,
May 8, 2013, 8:08:22 AM5/8/13
to ios-d...@googlegroups.com
Hi,

I tried with the same UICatalog example , wanted to do some action on the web view .

Can you please tell me how to build the xpath by id or name , or can we use className as in the example below 

public static void main(String[] args) throws MalformedURLException {

// TODO Auto-generated method stub


IOSCapabilities catalog = IOSCapabilities.iphone("UICatalog");


      RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), catalog);

      // by default, the app starts in native mode.

      WebElement web = driver.findElement(By.xpath("//UIATableCell[contains(@name,'Web')]"));

      web.click();

      // now that a webview is displayed, switch to web mode.

      driver.switchTo().window("Web");

  WebElement el = driver.findElement(By.className("UIALink"));

// Get the error when executing the above line.     

Dimension a =  el.getSize();

System.out.println(a);    

      driver.quit();

}



Can someone please help me this . Screenshot attached of the webview

Screen Shot 2013-05-08 at 5.37.42 PM.png

François Reynaud

unread,
May 8, 2013, 9:33:44 AM5/8/13
to sai krishna, ios-d...@googlegroups.com
Hello,

please make sure you read all the documentation.

after switchTo().windwo(Web) , it's dom selector, not native ones anymore.

thanks,
françois

sai krishna

unread,
Jul 17, 2013, 2:48:30 AM7/17/13
to ios-d...@googlegroups.com
Hi,

In my application there is a webview which is directing me to linkedin login page , when i try to give a command 
    driver.switchTo().window("Web"); 

FAILED: findElementByTagName

org.openqa.selenium.NoSuchWindowException: Cannot switch to window Web

Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: '1.6.0_43'

Driver info: driver.version: unknown

Command duration or timeout: 144 milliseconds

Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: '1.6.0_43'

Driver info: driver.version: RemoteWebDriver

Session ID: 23cedcbc-1fc2-42ba-b554-1ec3987d18ab

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)

at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)

at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:790)

at com.test.IphoneDriver.LinkUp.findElementByTagName(LinkUp.java:35)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)

at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)

at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)

at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)

at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)

at org.testng.TestRunner.privateRun(TestRunner.java:767)

at org.testng.TestRunner.run(TestRunner.java:617)

at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)

at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)

at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

at org.testng.SuiteRunner.run(SuiteRunner.java:240)

at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)

at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)

sai krishna

unread,
Jul 17, 2013, 3:17:10 AM7/17/13
to ios-d...@googlegroups.com

Please find the screenshot of my application on the inspector


On Wednesday, May 8, 2013 5:38:22 PM UTC+5:30, sai krishna wrote:
Reply all
Reply to author
Forward
0 new messages