# Unable to login inside the webview content

**URL:** <https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460>\
**Category:** Issues/Bugs\
**Created:** [March 20, 2015, 5:39am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460 "2015-03-20T05:39:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashokkumarg](https://discuss.appium.io/user_avatar/discuss.appium.io/ashokkumarg/32/9086_2.png) [@ashokkumarg](https://discuss.appium.io/u/ashokkumarg)\
**Post date:** [March 20, 2015, 5:39am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/1 "2015-03-20T05:39:17Z")

</div>

I’m trying to run a Hybrid application through the Genymotion Emulator with Appium 1.3.4.1.

**Started the appium server and eclipse.**

Now the emulator is running but in eclipse console an error message is displayed ❗

Randomly I am getting these four errors:

> 1. A new session could not be created. (Original error: UiAutomator quit before it successfully launched)
> 2. A new session could not be created. (Original error: Screen did not unlock)
> 3. A new session could not be created. (Original error: Android device not found)
> 4. A new session could not be created. (Original error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity)

**Then I start the emulator manually and then I click the run button in eclipse.**

By that time am not getting the above error message: It is going in to webview content but not able to find the element.

The error message is:

> Exception in thread “main” org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)  
> Command duration or timeout: 15.45 seconds

Appium Settings:

_Override Existing session = false_

![](https://discuss.appium.io/uploads/default/795/883d33bd1a184242.png)

Here is my code

```
public static void main(String[] args) throws InterruptedException, ExecuteException, IOException {
        // TODO Auto-generated method stub
     
        String deviceName = "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920";
     
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); 
        capabilities.setCapability("deviceName","Google Nexus 5 - 4.4.4 - API 19 - 1080x1920");    
        capabilities.setCapability("platformVersion", "4.4.4");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("app","D:/SOFTWARES/Apks/Hybrid.apk");

        **Starting the thirdy party genymotion emulator from the code.**

        DefaultExecutor executor = new DefaultExecutor();
        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
     
        CommandLine launchEmul = new CommandLine("C:/Program Files/Genymobile/Genymotion/player");
        launchEmul.addArgument("--vm-name");
        launchEmul.addArgument("\""+deviceName+"\"");
        executor.setExitValue(1);
        executor.execute(launchEmul, resultHandler);
        Thread.sleep(40);
                
        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
        System.out.println("SetUp is successful and Appium Driver is launched successfully");
        
        Login();
    }
    
    public static void Login() throws InterruptedException
    {   
     **Trying to do the login process in the Webview application**

    Set<String> contextNames = driver.getContextHandles();
        for (String contextName : contextNames) {
            System.out.println(contextName);
                        
          if (contextName.contains("WEBVIEW")){
             
              System.out.println("Application Loaded");
                           
             driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); 
                
              driver.findElement(By.id("txtUserName")).clear();
              driver.findElement(By.id("txtUserName")).sendKeys("test1@gmail.com");
                      
              driver.findElement(By.id("txtPassword")).clear();
              driver.findElement(By.id("txtPassword")).sendKeys("test1");
                      
              driver.findElement(By.id("btnLogin")).click();
          }
       }

```

The error is occuring when it is starting to find the **txtUserName** field

Before 3 days this same code worked very well. But now it is not working. I need some suggestions 😕 .

---

<div class="post-metadata">

**Author:** ![ashokkumarg](https://discuss.appium.io/user_avatar/discuss.appium.io/ashokkumarg/32/9086_2.png) [@ashokkumarg](https://discuss.appium.io/u/ashokkumarg)\
**Post date:** [March 20, 2015, 5:40am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/2 "2015-03-20T05:40:42Z")

</div>

@SergeyTichomirov Can you help me over this

---

<div class="post-metadata">

**Author:** ![SergeyTichomirov](https://discuss.appium.io/user_avatar/discuss.appium.io/sergeytichomirov/32/5175_2.png) [@SergeyTichomirov](https://discuss.appium.io/u/SergeyTichomirov)\
**Post date:** [March 20, 2015, 8:47am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/3 "2015-03-20T08:47:16Z")

</div>

Hi @ashokkumarg!

Ok. I will try to help you 😄  
Let’s resolve the first problem!

> [@ashokkumarg](#):
>
> A new session could not be created. (Original error: UiAutomator quit before it successfully launched)  
> A new session could not be created. (Original error: Screen did not unlock)  
> A new session could not be created. (Original error: Android device not found)

I am suspecting that your Genymotion settings have to be changed. Please check your ADB settings:  
1.

![](https://discuss.appium.io/uploads/default/796/fc0e011e614be309.png)

1. 

![](https://discuss.appium.io/uploads/default/797/b9284a2a53859886.png)

You have to specify the file path where Android SDK is installed.

---

<div class="post-metadata">

**Author:** ![ashokkumarg](https://discuss.appium.io/user_avatar/discuss.appium.io/ashokkumarg/32/9086_2.png) [@ashokkumarg](https://discuss.appium.io/u/ashokkumarg)\
**Post date:** [March 20, 2015, 9:07am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/4 "2015-03-20T09:07:04Z")

</div>

@SergeyTichomirov Thank you very much. I have tried with the following settings.

But still the issue is there.  
1.  
 ![](https://discuss.appium.io/uploads/default/798/fafc6b53befb4bc4.png)

---

<div class="post-metadata">

**Author:** ![SergeyTichomirov](https://discuss.appium.io/user_avatar/discuss.appium.io/sergeytichomirov/32/5175_2.png) [@SergeyTichomirov](https://discuss.appium.io/u/SergeyTichomirov)\
**Post date:** [March 20, 2015, 9:16am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/5 "2015-03-20T09:16:56Z")

</div>

Ok. Lets go forward  
I think there is no need to use this code fragment is you’ve set up the path to Android SDK:

> [@ashokkumarg](#):
>
> ```
> capabilities.setCapability("deviceName","Google Nexus 5 - 4.4.4 - API 19 - 1080x1920");    
> capabilities.setCapability("platformVersion", "4.4.4");
> capabilities.setCapability("platformName", "Android");
> capabilities.setCapability("app","D:/SOFTWARES/Apks/Hybrid.apk");
> 
> **Starting the thirdy party genymotion emulator from the code.**
> 
> DefaultExecutor executor = new DefaultExecutor();
> DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
>  
> CommandLine launchEmul = new CommandLine("C:/Program Files/Genymobile/Genymotion/player");
> launchEmul.addArgument("--vm-name");
> launchEmul.addArgument("\""+deviceName+"\"");
> executor.setExitValue(1);
> executor.execute(launchEmul, resultHandler);
> Thread.sleep(40);
> 
> ```

The code below works for me:

> ```
> capabilities.setCapability("deviceName","Android Emulator"); //!!! Please pay attention
> 
> ```

```
    capabilities.setCapability("platformVersion", "4.4.4");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("app", YouPathToApk);
    ....
    //other actions

```

Please try it.

---

<div class="post-metadata">

**Author:** ![ashokkumarg](https://discuss.appium.io/user_avatar/discuss.appium.io/ashokkumarg/32/9086_2.png) [@ashokkumarg](https://discuss.appium.io/u/ashokkumarg)\
**Post date:** [March 20, 2015, 10:10am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/6 "2015-03-20T10:10:57Z")

</div>

I too have done the same thing, which you mentioned above.

```
capabilities.setCapability("deviceName","Google Nexus 5 - 4.4.4 - API 19 - 1080x1920");    
capabilities.setCapability("platformVersion", "4.4.4");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app","D:/SOFTWARES/Apks/Hybrid.apk");

        DefaultExecutor executor = new DefaultExecutor();
        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        
        //The Genymotion emulator path
        CommandLine launchEmul = new CommandLine("C:/Program Files/Genymobile/Genymotion/player");
        launchEmul.addArgument("--vm-name");
        launchEmul.addArgument("\""+deviceName+"\"");
        executor.setExitValue(1);
        executor.execute(launchEmul, resultHandler);
        Thread.sleep(40);

        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
        System.out.println("SetUp is successful and Appium Driver is launched successfully");

```

But still the same issue.

Are you starting your Genymotion from appium launch AVD or through code.  
If you are starting it from appium can you post the settings.

---

<div class="post-metadata">

**Author:** ![ashokkumarg](https://discuss.appium.io/user_avatar/discuss.appium.io/ashokkumarg/32/9086_2.png) [@ashokkumarg](https://discuss.appium.io/u/ashokkumarg)\
**Post date:** [March 20, 2015, 10:32am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/7 "2015-03-20T10:32:08Z")

</div>

I couldn’t able to start the Emulator through the code.  
But if I start the emulator manually, it fails to find the webview elements.

---

<div class="post-metadata">

**Author:** ![ashokkumarg](https://discuss.appium.io/user_avatar/discuss.appium.io/ashokkumarg/32/9086_2.png) [@ashokkumarg](https://discuss.appium.io/u/ashokkumarg)\
**Post date:** [March 31, 2015, 4:35am UTC](https://discuss.appium.io/t/unable-to-login-inside-the-webview-content/3460/8 "2015-03-31T04:35:36Z")

</div>

@SergeyTichomirov Waiting for your reply
