0

Having the following code:

[TestClass]
public class RepairMobileTests
{

    public AppiumDriver driver;
    public DesiredCapabilities capabilities;


    [TestInitialize]
    public void BeforeAll()
    {

        capabilities = new DesiredCapabilities();
        capabilities.SetCapability("device", "Android");
        capabilities.SetCapability(CapabilityType.Platform, "WINDOWS");
        capabilities.SetCapability(CapabilityType.BrowserName, "Chrome");
        capabilities.SetCapability("deviceName", ConfigurationManager.AppSettings["deviceName"]);
        capabilities.SetCapability("platformName", ConfigurationManager.AppSettings["platformName"]);
        capabilities.SetCapability("platformVersion", ConfigurationManager.AppSettings["platformVersion"]);
        capabilities.SetCapability("appPackage", ConfigurationManager.AppSettings["appPackage"]);
        capabilities.SetCapability("appActivity", ConfigurationManager.AppSettings["appActivity"]);
   capabilities.SetCapability("capability.policy.strict.Window.confirm", "noAccess");
    }

    [TestCleanup]
    public void AfterAll()
    {
        driver.Quit();
    }
    [TestMethod]
    public void LoginSuccessful()
    {
        WaitMethods wm = new WaitMethods();
        driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(180));
        string homepage = "http://www.siteundertest.com/";
        string username = "user";
        string password = "pass";

        ProdemandLoginPage pdl = new ProdemandLoginPage();
        pdl.openPage(homepage, driver);

        //Thread.Sleep(10000);

        wm.WaitForAjax(driver);

        driver.HideKeyboard(); // here is thrown the error


    }
}

Error that is thrown:

Test Name:  SearchMenu
Test FullName:  RepairMobileTestAutomation.RepairMobileTests.SearchMenu
Test Source:    c:\Users\net\Documents\Visual Studio 2013\Projects\RepairMobileTestAutomation\RepairMobileTestAutomation\RepairMobileTests.cs : line 419
Test Outcome:   Failed
Test Duration:  0:00:19.5419473

Result Message: 
Test method RepairMobileTestAutomation.RepairMobileTests.SearchMenu threw exception: 
OpenQA.Selenium.WebDriverException: Unexpected error. unknown command: session/0a3e8c760809af9316358a5afa458541/appium/device/hide_keyboard
Result StackTrace:  
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Appium.AppiumDriver.HideKeyboard(String strategy, String key)
at OpenQA.Selenium.Appium.AppiumDriver.HideKeyboard()
at RepairMobileTestAutomation.RepairMobileTests.SearchMenu() in c:\Users\net\Documents\Visual Studio 2013\Projects\RepairMobileTestAutomation\RepairMobileTestAutomation\RepairMobileTests.cs:line 437

Appium logs are here http://pastebin.com/4jdJLnY8 I'm running the tests on real devices but i have multiple problems with Touch, Swipe, lock device, hidekeyboard and other gestures. How can I trigger events like tap or scroll down? Can someone post an example? I'm also trying to rotate the screen but nothing happens. Is there a way to do that? I'm running the tests on Chrome app which is installed on device.

sarbo
  • 1,661
  • 6
  • 21
  • 26

1 Answers1

0

If your using Android you can use self.driver.back() command to hide the keyboard using Appium, i use python, i use the following code after entering keys via Softkeyboard and it closes the keyboard and reveals the items hidden below keyboard

def test_sign_in_old(self):
        self.driver.implicitly_wait(10)
        print('Checking Already registered  user')
        self.driver.find_element_by_name("I'M A MEMBER").click()
        self.driver.find_element_by_id('com.XXX.android:id/m_emailTextField').send_keys('xxx@gmail.com')
        self.driver.find_element_by_id('com.XXX.android:id/m_passwordTextField').send_keys("1234abcd")
        self.driver.back()
        self.driver.implicitly_wait(5)
krishna chetan
  • 659
  • 1
  • 10
  • 20
  • can't do that with the c# library. I'm using AppiumDriver but I don't have the **back** method. – sarbo Mar 27 '15 at 12:41