0

I have used appium 1.6.4 and android version is on 5.1 ,6.1 and 7.0

enter image description here

Below is my code

public boolean navigateToLoginPage(){

    String strng = null;
    newObj = new LogInPage();
    wait = new WebDriverWait(driver,20);
    wait.until(ExpectedConditions.visibilityOf(GetStarted));
    GetStarted.click();
    driver.manage().timeouts().implicitlyWait(5000, TimeUnit.MILLISECONDS);

    if(Country.isDisplayed()){
        Country.click();
        wait.until(ExpectedConditions.visibilityOf(Cancel));
        Cancel.click();
    } 
    driver.manage().timeouts().implicitlyWait(4000, TimeUnit.MILLISECONDS); 
    MobileNumber.sendKeys("91**********");

    Next.click();
    driver.manage().timeouts().implicitlyWait(3000, TimeUnit.MILLISECONDS);
    OK.click();// this is the problem , this sometimes works sometimes not 

//i have used the alert interface but no use

//if(OK.isEnabled()){OK.click();} it returns true and I have also used .isDisplayed but no use

//When Ok button is not clicked but the code in the try block is executed //I have also used the tap functionality but no effect

        try {
            strng =newObj.try1();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    wait.until(ExpectedConditions.visibilityOf(EnterOTP));
    EnterOTP.sendKeys(strng);
    Next.click();
    return true;    
}
abishek kachroo
  • 35
  • 1
  • 11
  • Duplicate of https://stackoverflow.com/questions/24635354/how-to-handle-alerts-in-android-using-appium/24641164#24641164 – Ivan Pronin Aug 07 '17 at 19:51
  • What does your page object look like? Also, implicit waits are generally set once, upon instantiation of the driver, then left alone. Implicit waits should probably be a bit longer, 10-30 seconds, Appium can be slow sometimes. If you setup your page objects correctly, you should not need anything but the initial implicit wait. If you have to do waits elsewhere they should be explicit waits. I'm curious how the page object is initialized, as you don't pass the driver. – Bill Hileman Aug 07 '17 at 19:57
  • i am using the page Factory and my page elements looks like this @FindBy(xpath ="//android.widget.LinearLayout[@text='Mobile']") WebElement MobileNumber; @FindBy(xpath ="//android.widget.Button[@text='Next']") WebElement Next; @FindBy(id ="com.edmobilelabs.sling.dev:id/btnPositive") WebElement OK; and in my base class i have instantiated android driver and all my test class extends my base class so driver issue is resolved and moreover I am passing the parameters by TestNG so no need to depend upon other class – abishek kachroo Aug 07 '17 at 20:18
  • @IvanPronin I have tried your code for switching the contexts , it worked for 2 time but again 3rd time it fails Here are my logs : {"strategy":"id","selector":"com.edmobilelabs.sling.dev:id/btnPositive","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.edmobilelabs.sling.dev:id/btnPositive' using 'ID' with the contextId: '' multiple: false //this is the required id – abishek kachroo Aug 07 '17 at 20:53
  • @IvanPronin I have checked the page source and found out that whenever the x & y co-ordinates or the bounds for the button are bounds="[323,639][516,680]" there is success and whenver it is bounds="[352,486][674,598]" button is not clicked and for my success bound should be always in between "[352,486][674,598]" and when I check my logs on the appium server when elementId is 5 there is success and when its not vice-versa Could you guys please suggest how can I over-come this issue ?? – abishek kachroo Aug 10 '17 at 07:02
  • @abishek kachroo, could you please update your question with the latest info: post whole code of finding elements and working with them with the results (fail / success) – Ivan Pronin Aug 10 '17 at 20:07
  • @IvanPronin I have created the whole new question as I was unable to edit this one or I didn't have the rights, here is the link for the new one :- https://stackoverflow.com/questions/45635657/unable-to-click-on-native-app-generated-pop-up-questions-is-i-am-able-to-click – abishek kachroo Aug 11 '17 at 12:50
  • Ok, will take a look – Ivan Pronin Aug 11 '17 at 20:10

0 Answers0