You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wait.until(ExpectedConditions.visibilityOf(elementName)) related issue #574
java client build version or git revision if you use some shapshot: 5.0.0-BETA3
Appium server version or git revision if you use some shapshot: 1.6.3
Desktop OS/version used to run Appium if necessary: Mac
Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe:
Mobile platform/version under test: iOS 10.2
Real device or emulator/simulator: simulator
Details
When I set wait , I expect element to wait for that time interval itself.
But value set for wait is ignored and element waits for default timeout mentioned in PageFactory.initElements
Later I tried @WithTimeout(time = 3, unit = TimeUnit.SECONDS) for this element but still it waits for defaulttime, my understanding is this particular tag overrides the default time.
WebDriverWait wait = new WebDriverWait(AppiumController.instance.driver, timeout)
Could you provide the value of timeout? I want to try it.
However there is an issue. There is a conflict of implicit and explicit waitings. I think it is design issue of Selenium. You can reproduce it on commom Selenium.
driver.manage().timeouts().implicitlyWait(30, SECONDS);
FluentWait<WebDriver> wait = newWebDriverWait(driver, 5);
wait.until(presenceOfElementLocated(By.id("fakeId"))); //if //the element is not present or doen't exist
It will wait for more than 30 seconds.
One more question. Does the element xpath = //XCUIElementTypeApplication[1]//XCUIElementTypeButton[contains(@label,'Already a member')] exist?
Per my understanding this is implicit wait which is applied to all the elements on this page , is this correct ?
Then in the same class; I've generic method which checks for both element availability and unavailability
public boolean isElementPresent(WebElement elementName, int timeout){
try{
WebDriverWait wait = new WebDriverWait(AppiumController.instance.driver, timeout);
wait.until(ExpectedConditions.visibilityOf(elementName));
return true;
}catch(Exception e){
return false;
}
}
Here I pass smallest amount of time possible, say 1 sec to check and return if element is absent, is this correct way of doing ?
xpath = //XCUIElementTypeApplication[1]//XCUIElementTypeButton[contains(@label,'Already a member')]
I check when this is suppose to be present and second instance it is suppose to be absent. For checking absent , I send 1 sec time interval but it waits for 10 sec as per implicit wait mentioned in constructor
Is this failing because of mixing both implicit and explicit wait as you mentioned ?
Isn't using @WithTimeout has an affect on implicit wait ?
Per my understanding this is implicit wait which is applied to all the elements on this page , is this correct ?
yes
Then in the same class; I've generic method which checks for both element availability and unavailability
...
Here I pass smallest amount of time possible, say 1 sec to check and return if element is absent, is this correct way of doing ?
I'm not sure. What the purpose? May be it is better to just ask
element.isDisplayed();
What are you trying to achieve? Is it some quick checking that is used for if/else?
So you can work it out these ways:
@WithTimeout(time = 100, unit = TimeUnit.MILLISECONDS)
...
WebElementelement
@TikhomirovSergey sorry for late reply, please find below info in which things go havoc ( I tried with java client project )
AndroidPageObjectTest.java
@WithTimeout(time = 4, unit = TimeUnit.SECONDS)
@FindBy(id = "android:id/text11") //this is invalid locator; purposely put up
private WebElement textView;
@Before public void setUp() throws Exception {
if (!populated) {
//This time out is set because test can be run on slow Android SDK emulator
PageFactory.initElements(new AppiumFieldDecorator(driver, 15, TimeUnit.SECONDS), this);
}
populated = true;
}
public boolean isElementPresent(WebElement elementName, int timeout){
//long time = duration.getTime();
//TimeUnit unit = duration.getTimeUnit();
try{
// duration.setTime(100, TimeUnit.MILLISECONDS);
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOf(elementName));
return true;
}catch(Exception e){
return false;
}
finally {
//duration.setTime(time, unit);
}
}
@Test public void findByElementTest() {//Vikram
//duration.setTime(10, TimeUnit.SECONDS);
isElementPresent(textView,2);
// assertNotEquals(null, textView.getAttribute("text"));
}
Here I have 3 times set for same element
4 sec at element declaration
2 sec for checking that it's absent
15 sec as implicit wait
In this case even though appium server log says
[debug] [BaseDriver] Set implicit wait to 0ms
[debug] [BaseDriver] Set implicit wait to 15000ms
Test takes 15+ sec.
I feel we should make it clear not to combine all the timeouts and mention good practices wrt its usage.
The same is true for the direct using of the implicit waiting.
Summary:
It is possible that there is an issue. I'm cahanging the label to "But". I suppose that something has to be optimized. But the fluent waiting won't take lesser time than implicit waiting time out.
PS:
[debug] [BaseDriver] Set implicit wait to 15000ms
It is normal behaviour. It reverts timeout to the general value.
@TikhomirovSergey Thanks a ton for detailed analysis, I know it's built in problem with Selenium. If we can manage in better way at client side, will be good for users.
Please let me know in case further info needed on this
@vikramvi , before u use explicit wait always remember to set 0 or minimal implicit wait, and reset it (Implicit wait) after your wait.until. This could be expected behaviour from selenium webdriver because ur explicit wait always user implicit wait as polling interval. So just for a try can u please increase waiting duration to 50 seconds.
Issue happens when I only use explicit wait and implicit wait ( not sure if this is selenium issue )
In this case, appium waits for 25 sec instead of 2 sec
It is not the issue. It is the normal behaviour. @priyankshah217 is right. And before I have adviced you to use @WithTimeOut with the minimal acceptable value.
Both explicit and implicit waits aren't working for appium.
Tried several ways, mentioning below one among them. As of now I am using explicit wait and it breaks at below line of code >> wait.until(ExpectedConditions.elementToBeClickable(element)); Error : NoSuchMethodError java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
JavaClient : 3.2
Appium Server Version : 1.4.16.1
JavaClient : 5.0.0Beta9
Guava : Version 21
Selenium-Java Version 2.53.1
Not able to figure out, where and what is going wrong. Your help is appreciated.
Hello @vikramvi and all,
The solutions provided here, waiting for an element to be visible works for me.
But i;m trying to find a solution for waiting for an element to not be visible anymore, for e.g.: a progress bar . I'm trying to tell appium to wait until the element is not visible and them continue with the tests.
Here is my sample:
I have Java client: 5.0.4
Appium Server Version :1.7.2
Selenium-Java Version 3.11
The problem is that sometimes, if the driver sincronize with the progress bar, it will spot that is no longer visible and continue with the test.
But most of the times, the bar is no longer visible and the driver keeps searching for it and say that no element found.
Is this method deprecated for Appium? Is there any method to wait until the element is no longer visible?
@vikramvi I asked, but unfortunately no so much success :(
I intend to believe it might be something with the wait.until conditions from the java client.
I have tried with all suitable expected conditions from the org.openqa.selenium.support.ui.ExpectedConditions, but nothing, keeps saying no element fount when the element is no longer visible in the page.
seems to work for me with uiAutomator2 latest version.
I was testing on android 6 with Appium automator.
uiAutomator work stable on android 7 and 8 platforms which I use now for testing
Activity
vikramvi commentedon Feb 16, 2017
@TikhomirovSergey @SrinivasanTarget @saikrishna321 I feel this issue is related to #572
please have a look
TikhomirovSergey commentedon Feb 16, 2017
Hi @vikramvi
I'm trying to reproduce the issue. It have not reproduced yet. I'm using that sample
Could you provide the value of
timeout? I want to try it.However there is an issue. There is a conflict of implicit and explicit waitings. I think it is design issue of Selenium. You can reproduce it on commom Selenium.
It will wait for more than 30 seconds.
One more question. Does the element
xpath = //XCUIElementTypeApplication[1]//XCUIElementTypeButton[contains(@label,'Already a member')]exist?Also I'am trying to read the log and it seems everything works ok.
Here it starts the searching
Here the searching ends. The value of timeout is reverted to 10 seconds
vikramvi commentedon Feb 17, 2017
@TikhomirovSergey Please find below answers
Per my understanding this is implicit wait which is applied to all the elements on this page , is this correct ?
Here I pass smallest amount of time possible, say 1 sec to check and return if element is absent, is this correct way of doing ?
xpath = //XCUIElementTypeApplication[1]//XCUIElementTypeButton[contains(@label,'Already a member')]I check when this is suppose to be present and second instance it is suppose to be absent. For checking absent , I send 1 sec time interval but it waits for 10 sec as per implicit wait mentioned in constructor
Is this failing because of mixing both implicit and explicit wait as you mentioned ?
Isn't using
@WithTimeouthas an affect on implicit wait ?timeoutI'm using 10 sec as implicit waitTikhomirovSergey commentedon Feb 17, 2017
@vikramvi
yes
I'm not sure. What the purpose? May be it is better to just ask
What are you trying to achieve? Is it some quick checking that is used for if/else?
So you can work it out these ways:
or
I think yes. I suppose that it is design issue of Selenium.
Sorry for delayng.
vikramvi commentedon Feb 20, 2017
@TikhomirovSergey sorry for late reply, please find below info in which things go havoc ( I tried with java client project )
Here I have 3 times set for same element
4 sec at element declaration
2 sec for checking that it's absent
15 sec as implicit wait
In this case even though appium server log says
[debug] [BaseDriver] Set implicit wait to 0ms
[debug] [BaseDriver] Set implicit wait to 15000ms
Test takes 15+ sec.
I feel we should make it clear not to combine all the timeouts and mention good practices wrt its usage.
TikhomirovSergey commentedon Feb 20, 2017
@vikramvi Will try to reproduce it on the sample above soon.
TikhomirovSergey commentedon Feb 20, 2017
@vikramvi Ok. It is interesting
The first sample
and
It took about 4.5 sec.
ok.
this test was failed
But you can see that
not 15 seconds. However it looks curiously.
Ok. One more sample.
Test passed.
But it took about 5 seconds, not 2 as it was expected.
Ok. The workaround for now.
And test passed
The same is true for the direct using of the implicit waiting.
Summary:
It is possible that there is an issue. I'm cahanging the label to "But". I suppose that something has to be optimized. But the fluent waiting won't take lesser time than implicit waiting time out.
PS:
It is normal behaviour. It reverts timeout to the general value.
vikramvi commentedon Feb 21, 2017
@TikhomirovSergey Thanks a ton for detailed analysis, I know it's built in problem with Selenium. If we can manage in better way at client side, will be good for users.
Please let me know in case further info needed on this
TikhomirovSergey commentedon Feb 21, 2017
@vikramvi I am going to research and try to find more optimal solution.
Merge pull request #582 from TikhomirovSergey/master
TikhomirovSergey commentedon Feb 25, 2017
@vikramvi The fix is merged and will be published at BETA4. Please take a look at the PR and close the issue
3 remaining items
priyankshah217 commentedon Mar 1, 2017
@vikramvi , before u use explicit wait always remember to set 0 or minimal implicit wait, and reset it (Implicit wait) after your wait.until. This could be expected behaviour from selenium webdriver because ur explicit wait always user implicit wait as polling interval. So just for a try can u please increase waiting duration to 50 seconds.
TikhomirovSergey commentedon Mar 1, 2017
@vikramvi
It is not the issue. It is the normal behaviour. @priyankshah217 is right. And before I have adviced you to use
@WithTimeOutwith the minimal acceptable value.TikhomirovSergey commentedon Mar 1, 2017
@vikramvi I am closing this ticke as
@WithTimeOutworks as expected. Please reopen it if there are some details.vikramvi commentedon Mar 1, 2017
Thanks @priyankshah217 @TikhomirovSergey for quick reply.
Thanks a ton @TikhomirovSergey for giving time for this issue & fixing
Closing as per above 2 comments.
MeghaRamprasad commentedon Aug 1, 2017
Hi @vikramvi and @TikhomirovSergey , Please help me with it.
Both explicit and implicit waits aren't working for appium.
Tried several ways, mentioning below one among them. As of now I am using explicit wait and it breaks at below line of code >> wait.until(ExpectedConditions.elementToBeClickable(element));
Error : NoSuchMethodError
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
JavaClient : 3.2
Appium Server Version : 1.4.16.1
JavaClient : 5.0.0Beta9
Guava : Version 21
Selenium-Java Version 2.53.1
Not able to figure out, where and what is going wrong. Your help is appreciated.
vikramvi commentedon Nov 7, 2017
@MeghaRamprasad Update Appium Server and Appium Java Client to latest versions.
zuzeac commentedon Apr 27, 2018
Hello @vikramvi and all,
The solutions provided here, waiting for an element to be visible works for me.
But i;m trying to find a solution for waiting for an element to not be visible anymore, for e.g.: a progress bar . I'm trying to tell appium to wait until the element is not visible and them continue with the tests.
Here is my sample:
I have Java client: 5.0.4
Appium Server Version :1.7.2
Selenium-Java Version 3.11
The problem is that sometimes, if the driver sincronize with the progress bar, it will spot that is no longer visible and continue with the test.
But most of the times, the bar is no longer visible and the driver keeps searching for it and say that no element found.
Is this method deprecated for Appium? Is there any method to wait until the element is no longer visible?
Thank you
vikramvi commentedon May 17, 2018
@zuzeac can you ask this query in https://discuss.appium.io/ ?
zuzeac commentedon May 23, 2018
@vikramvi I asked, but unfortunately no so much success :(
I intend to believe it might be something with the wait.until conditions from the java client.
I have tried with all suitable expected conditions from the org.openqa.selenium.support.ui.ExpectedConditions, but nothing, keeps saying no element fount when the element is no longer visible in the page.
Here is the thread:
https://discuss.appium.io/t/wait-for-element-to-disappear-not-be-preset-anymore/22122
narendra-chandratre commentedon Aug 3, 2018
yes agree. But doesn't work even using latest version 6.1.0 too :(
Anyone fix this issue?
zuzeac commentedon Aug 3, 2018
seems to work for me with uiAutomator2 latest version.
I was testing on android 6 with Appium automator.
uiAutomator work stable on android 7 and 8 platforms which I use now for testing
narendra-chandratre commentedon Aug 13, 2018
Can you additionally specify which versions of Appium, Java-client and uiAutomator you are using?
zuzeac commentedon Aug 13, 2018
Appium 1.8.1
Java client 6.1.0
UiAutomator2 latest version. Not sure right now the number.
tush20010 commentedon Aug 16, 2022
I am facing issues with appium 8.1.1 can anyone help how to resolve it