question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Appium is kept retrying to find the webElement and not executing the else condition

See original GitHub issue

The problem

I have a condition where I have to click on one Web Element till the new element appears and then to come out of the loop But appium continues try to find the new element

Environment

  • Appium 1.6.5 version

Details

Here is mine code

@FindBy(id="Some Id which Appium keeps on trying to find")
List<WebElement>  SessionEnded;

BotButtonForChat.click();
	while(BotButtonForChat.isDisplayed()){
		int len =SessionEnded.size(); // it gets stucked at this point
		System.out.println(len);
		if(len>0){
			break;
		}
		else{
			wai8.until(ExpectedConditions.visibilityOf(BotButtonForChat));
			BotButtonForChat.click();
		}
	}

I have used the Boolean also like Boolean isPresent = driver.findElements(By.id(“Some Id”)).size() > 0; if(isPresent.isDisplayed()){ do some action } else { Do some Action} I have also tried with Try catch logic

Link to Appium logs

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[RESOURCE_ID=“My Element Id”] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0) [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=com.edmobilelabs.betterplace.dev:id/tvCmdText] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.

I have tried the same type of logic while using Selenium on automating webapps , It works every Time Is there some sort of Work Around Please explain the answer or some logic in java code

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
imurchiecommented, Feb 15, 2019

Please post the full logs as a link to a gist. Also, what is it that you are trying to do? The little bit of logs here is just not finding an element.

0reactions
lock[bot]commented, Feb 15, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to continue script when element is not found in selenium
Use findElements instead of findElement . findElements will return an empty list if no matching elements are found instead of an exception.
Read more >
Else condition not working - Issues/Bugs - Appium Discuss
Hi, The else condition is not working in appium;only the if part gets executed. If the element is not found else condition should...
Read more >
Appium findElement used twice in one row not working
When using xpath be aware that webdriver follows standard conventions: a search prefixed with "//" will search the entire document, not just the...
Read more >
Top 10 Selenium Exceptions and How To Handle These ...
Handling Exceptions in Selenium WebDriver - In this tutorial we will learn about types of exceptions and how to handle top 10 most...
Read more >
How To Use isDisplayed() In Selenium WebDriver - LambdaTest
Ever wondered why is it so? There are multiple reasons for getting this exception, but among those, we wouldn't have checked if the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found