Android Appium - Implicit Wait on AndroidDriver Appium Doesn't Work
up vote
1
down vote
favorite
I've some problem with AndroidDriver in Appium,
Currently I am using this code to wait several time to give my App Log in / Registration process.
BasePage Class :
protected AndroidDriver driver;
public BasePage(AndroidDriver driver)
this.driver = driver;
public void waitFor(int second)
driver.manage().timeouts().implicitlyWait(second, TimeUnit.SECONDS);
and implement on this class :
public class RegistrationPage extends base.BasePage {
public RegistrationPage(AndroidDriver driver)
super(driver);
public RegistrationPage alreadyExistRegistration() {
waitForVisibilityOf(button_login);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
driver.findElement(button_register).click();
driver.findElement(input_dob).click();
driver.findElement(ok).click();
driver.findElement(phone_no).sendKeys("888888888");
driver.findElement(setup_pin).sendKeys("1111");
driver.findElement(confirm_pin).sendKeys("1111");
tapAndroid(840,1832);
driver.findElement(check_term).click();
driver.findElement(btn_next).click();
waitFor(10);
Assert.assertTrue(driver.findElement(message).getText().equalsIgnoreCase("Your Number is Already Registered"));
I have edited the parameter up to 50 second but there is no wait in Junit test. Before using AndroidDriver I am using WebDriver and it works well, but I need Android Driver to do TouchAction.
So my test case always fail because when the assert run it will find element immediately while it is not available yet.
appium appium-android
add a comment |
up vote
1
down vote
favorite
I've some problem with AndroidDriver in Appium,
Currently I am using this code to wait several time to give my App Log in / Registration process.
BasePage Class :
protected AndroidDriver driver;
public BasePage(AndroidDriver driver)
this.driver = driver;
public void waitFor(int second)
driver.manage().timeouts().implicitlyWait(second, TimeUnit.SECONDS);
and implement on this class :
public class RegistrationPage extends base.BasePage {
public RegistrationPage(AndroidDriver driver)
super(driver);
public RegistrationPage alreadyExistRegistration() {
waitForVisibilityOf(button_login);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
driver.findElement(button_register).click();
driver.findElement(input_dob).click();
driver.findElement(ok).click();
driver.findElement(phone_no).sendKeys("888888888");
driver.findElement(setup_pin).sendKeys("1111");
driver.findElement(confirm_pin).sendKeys("1111");
tapAndroid(840,1832);
driver.findElement(check_term).click();
driver.findElement(btn_next).click();
waitFor(10);
Assert.assertTrue(driver.findElement(message).getText().equalsIgnoreCase("Your Number is Already Registered"));
I have edited the parameter up to 50 second but there is no wait in Junit test. Before using AndroidDriver I am using WebDriver and it works well, but I need Android Driver to do TouchAction.
So my test case always fail because when the assert run it will find element immediately while it is not available yet.
appium appium-android
i am having the same issue. Currently i am using ExplicitWait and Thread.sleep() method.
– Suban Dhyako
Nov 12 at 13:33
yeah, for now i am using Thread.sleep() from java it self. will try ExplicitWait, i hope this also works.
– Azzam.A.H
Nov 13 at 16:21
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I've some problem with AndroidDriver in Appium,
Currently I am using this code to wait several time to give my App Log in / Registration process.
BasePage Class :
protected AndroidDriver driver;
public BasePage(AndroidDriver driver)
this.driver = driver;
public void waitFor(int second)
driver.manage().timeouts().implicitlyWait(second, TimeUnit.SECONDS);
and implement on this class :
public class RegistrationPage extends base.BasePage {
public RegistrationPage(AndroidDriver driver)
super(driver);
public RegistrationPage alreadyExistRegistration() {
waitForVisibilityOf(button_login);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
driver.findElement(button_register).click();
driver.findElement(input_dob).click();
driver.findElement(ok).click();
driver.findElement(phone_no).sendKeys("888888888");
driver.findElement(setup_pin).sendKeys("1111");
driver.findElement(confirm_pin).sendKeys("1111");
tapAndroid(840,1832);
driver.findElement(check_term).click();
driver.findElement(btn_next).click();
waitFor(10);
Assert.assertTrue(driver.findElement(message).getText().equalsIgnoreCase("Your Number is Already Registered"));
I have edited the parameter up to 50 second but there is no wait in Junit test. Before using AndroidDriver I am using WebDriver and it works well, but I need Android Driver to do TouchAction.
So my test case always fail because when the assert run it will find element immediately while it is not available yet.
appium appium-android
I've some problem with AndroidDriver in Appium,
Currently I am using this code to wait several time to give my App Log in / Registration process.
BasePage Class :
protected AndroidDriver driver;
public BasePage(AndroidDriver driver)
this.driver = driver;
public void waitFor(int second)
driver.manage().timeouts().implicitlyWait(second, TimeUnit.SECONDS);
and implement on this class :
public class RegistrationPage extends base.BasePage {
public RegistrationPage(AndroidDriver driver)
super(driver);
public RegistrationPage alreadyExistRegistration() {
waitForVisibilityOf(button_login);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
swipeAndroid(1000, 1000, 100, 1000);
waitFor(1);
driver.findElement(button_register).click();
driver.findElement(input_dob).click();
driver.findElement(ok).click();
driver.findElement(phone_no).sendKeys("888888888");
driver.findElement(setup_pin).sendKeys("1111");
driver.findElement(confirm_pin).sendKeys("1111");
tapAndroid(840,1832);
driver.findElement(check_term).click();
driver.findElement(btn_next).click();
waitFor(10);
Assert.assertTrue(driver.findElement(message).getText().equalsIgnoreCase("Your Number is Already Registered"));
I have edited the parameter up to 50 second but there is no wait in Junit test. Before using AndroidDriver I am using WebDriver and it works well, but I need Android Driver to do TouchAction.
So my test case always fail because when the assert run it will find element immediately while it is not available yet.
appium appium-android
appium appium-android
edited Nov 14 at 8:57
Wasiq Bhamla
59039
59039
asked Nov 12 at 7:23
Azzam.A.H
9011
9011
i am having the same issue. Currently i am using ExplicitWait and Thread.sleep() method.
– Suban Dhyako
Nov 12 at 13:33
yeah, for now i am using Thread.sleep() from java it self. will try ExplicitWait, i hope this also works.
– Azzam.A.H
Nov 13 at 16:21
add a comment |
i am having the same issue. Currently i am using ExplicitWait and Thread.sleep() method.
– Suban Dhyako
Nov 12 at 13:33
yeah, for now i am using Thread.sleep() from java it self. will try ExplicitWait, i hope this also works.
– Azzam.A.H
Nov 13 at 16:21
i am having the same issue. Currently i am using ExplicitWait and Thread.sleep() method.
– Suban Dhyako
Nov 12 at 13:33
i am having the same issue. Currently i am using ExplicitWait and Thread.sleep() method.
– Suban Dhyako
Nov 12 at 13:33
yeah, for now i am using Thread.sleep() from java it self. will try ExplicitWait, i hope this also works.
– Azzam.A.H
Nov 13 at 16:21
yeah, for now i am using Thread.sleep() from java it self. will try ExplicitWait, i hope this also works.
– Azzam.A.H
Nov 13 at 16:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I think you got the concept of implicit waits wrong. We don't need to set it every time. We need to set it once while driver initialization with maximum time out like 60 secs and it will wait for element when finding it.
Along with it, you can use explicit wait with a time out value greater than 1 minute like,
WebDriverWait wait = new WebDriverWait (driver, 120);
And use it's method,
wait.until (ExpectedConditions.visibilityOfElementLocated (By.id ("your ID")));
Once this is done, you don't need to call waitFor
methods everywhere in your code.
This is working fine for me and I never use Thread.sleep()
😉.
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
actually i have create this function :protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this :waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.
– Azzam.A.H
Nov 22 at 10:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257500%2fandroid-appium-implicit-wait-on-androiddriver-appium-doesnt-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I think you got the concept of implicit waits wrong. We don't need to set it every time. We need to set it once while driver initialization with maximum time out like 60 secs and it will wait for element when finding it.
Along with it, you can use explicit wait with a time out value greater than 1 minute like,
WebDriverWait wait = new WebDriverWait (driver, 120);
And use it's method,
wait.until (ExpectedConditions.visibilityOfElementLocated (By.id ("your ID")));
Once this is done, you don't need to call waitFor
methods everywhere in your code.
This is working fine for me and I never use Thread.sleep()
😉.
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
actually i have create this function :protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this :waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.
– Azzam.A.H
Nov 22 at 10:45
add a comment |
up vote
0
down vote
I think you got the concept of implicit waits wrong. We don't need to set it every time. We need to set it once while driver initialization with maximum time out like 60 secs and it will wait for element when finding it.
Along with it, you can use explicit wait with a time out value greater than 1 minute like,
WebDriverWait wait = new WebDriverWait (driver, 120);
And use it's method,
wait.until (ExpectedConditions.visibilityOfElementLocated (By.id ("your ID")));
Once this is done, you don't need to call waitFor
methods everywhere in your code.
This is working fine for me and I never use Thread.sleep()
😉.
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
actually i have create this function :protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this :waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.
– Azzam.A.H
Nov 22 at 10:45
add a comment |
up vote
0
down vote
up vote
0
down vote
I think you got the concept of implicit waits wrong. We don't need to set it every time. We need to set it once while driver initialization with maximum time out like 60 secs and it will wait for element when finding it.
Along with it, you can use explicit wait with a time out value greater than 1 minute like,
WebDriverWait wait = new WebDriverWait (driver, 120);
And use it's method,
wait.until (ExpectedConditions.visibilityOfElementLocated (By.id ("your ID")));
Once this is done, you don't need to call waitFor
methods everywhere in your code.
This is working fine for me and I never use Thread.sleep()
😉.
I think you got the concept of implicit waits wrong. We don't need to set it every time. We need to set it once while driver initialization with maximum time out like 60 secs and it will wait for element when finding it.
Along with it, you can use explicit wait with a time out value greater than 1 minute like,
WebDriverWait wait = new WebDriverWait (driver, 120);
And use it's method,
wait.until (ExpectedConditions.visibilityOfElementLocated (By.id ("your ID")));
Once this is done, you don't need to call waitFor
methods everywhere in your code.
This is working fine for me and I never use Thread.sleep()
😉.
answered Nov 14 at 7:19
Wasiq Bhamla
59039
59039
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
actually i have create this function :protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this :waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.
– Azzam.A.H
Nov 22 at 10:45
add a comment |
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
actually i have create this function :protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this :waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.
– Azzam.A.H
Nov 22 at 10:45
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
well, i ll try this, i hope it works. thanks
– Azzam.A.H
Nov 22 at 10:32
actually i have create this function :
protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this : waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.– Azzam.A.H
Nov 22 at 10:45
actually i have create this function :
protected void waitForVisibilityOf(By locator) WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
and called on the implementation like this : waitForVisibilityOf(button_login);
but this doesn't work. i think because i am using Android Driver previously using Web Driver and it works.– Azzam.A.H
Nov 22 at 10:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257500%2fandroid-appium-implicit-wait-on-androiddriver-appium-doesnt-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
i am having the same issue. Currently i am using ExplicitWait and Thread.sleep() method.
– Suban Dhyako
Nov 12 at 13:33
yeah, for now i am using Thread.sleep() from java it self. will try ExplicitWait, i hope this also works.
– Azzam.A.H
Nov 13 at 16:21