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.

|Ruby| How does one assert that certain element is not visible on the screen

See original GitHub issue

Assert that element is not visible on the screen

Hi guys, I am having difficulties to assert that certain text is not visible on the screen. I have tried my luck with RSpec Expectations, and different approaches which would be working for web app. However with Appium it does not seem to work.

Here is the link of what I have tried: http://stackoverflow.com/questions/38372530/appium-how-does-one-assert-that-certain-text-is-not-displayed-on-the-screen

There are many examples, how to assert that something IS visible, and that is working as expected. However when its vice versa then it is not going smoothly.

What is your experience in this situation?

Environment

* Mobile app - iOS
* Appium 1.5.2 + Cucumber + WatirWebdriver + Ruby + RSpec Expectations

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JaniJegoroffcommented, Jul 20, 2016

I’m using Appium Ruby bindings and here is an example what I do in such cases:

[1] pry(main)> wait_true { ignore { text('text that is not visible on screen') }.nil? }
true

Same example with a text that is visible on screen:

[2] pry(main)> wait_true { ignore { text('Media') }.nil? }
Selenium::WebDriver::Error::TimeOutError: timed out after 30 seconds
1reaction
JaniJegoroffcommented, Jul 20, 2016

No problem - hope this brief explanation helps.

wait_true { ignore { text('text that is not visible on screen') }.nil? }

wait_true, ignore and text are Appium Ruby binding methods and can be found from project: https://github.com/appium/ruby_lib

text will return the first “textfield” element with given text. Since such element is not going to be found it will throw an exception. We will catch exception with ignore block. When text is not found ignore block will return nil. Finally we use wait_true block to poll that return value is nil meaning text is not visible on the screen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

rspec - |Appium - Ruby| How does one assert that certain text ...
In a scenario I want to assert that text "Something" is not displayed on the screen. This is a test for mobile iOS...
Read more >
Quicker way to assert that an element does not exist
This works fine for the test: to assert if the popup exists. But as soon as I change the goal to: assert if...
Read more >
Check Visibility of Web Elements Using Various Types ...
The method returns a “true” value if the specified web element is present on the web page and a “false” value if the...
Read more >
How to check that an element does not exist on the screen ...
In today's “Pinches of Cypress”, learn how to check that an element is not present at the DO... Tagged with cypress, testing, automtion, ......
Read more >
Verifying whether an element present or ... - Tutorialspoint
To check the visibility of an element in a page, the method isDisplayed is used. It returns a Boolean value( true is returned...
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