Selenium Webdriver: How to pause execution until specific text appears on the webpage

I have attempted the following methods:

driver.wait(function() {
  return driver.isElementPresent(webdriver.findElement(By.xpath("//*[contains(text(),'Vanilla Sky Final Scene')]")))
}, 20000).then(function() {
  console.log('worked')
})

as well as this:

driver.wait(function() {
  return driver.isElementPresent(driver.findElement(By.xpath("//*[contains(text(),'Vanilla Sky Final Scene')]")))
}, 20000).then(function() {
  console.log('worked')
})

And this:

driver.wait(function() {
  return driver.findElement(By.xpath("//*[contains(text(),'Vanilla Sky Final Scene')]")))
}, 20000).then(function() {
  console.log('worked')
})

Unfortunately, none of these approaches are yielding the desired results. Can someone suggest the correct way to achieve this?

Answer №1

To check if an element is displayed, use the isDisplayed() function as shown below:

driver.wait(function() {
  return driver.findElement(By.xpath("//*[contains(text(),'Vanilla Sky Final Scene')]")).isDisplayed();
}, 20000);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error message: "Attempting to assign a value to the 'size' property of an undefined object, despite the fact that

I recently started delving into NodeJS development and have configured Visual Studio Code for JavaScript development in node applications. During a Pluralsight lecture on Objects, the instructor demonstrated creating two scripts, dice.js and program.js, a ...

What is the best way to pass data from a parent component to a child component and utilize it within a function in Next.js

As a beginner in react and nextjs, I am struggling with passing the "response" from a function in the parent component to another component (component1). function func1(props) { function handleSubmit(e) { e.preventDefault(); v ...

How can I repeatedly show text using knockout js?

How can I use KnockoutJS to display the text and year within a div loop when selecting a brand and model? Example: Mercedes>C *C-180 *2016 *C-200 *2015 Here is the HTML code: <select data-bind="options: manufacturers, optionsCaption:'Bra ...

Unable to successfully add element to array using UIKit modal in vuejs

On my webpage, I have a table that showcases an array of "currency" objects: <tbody> <tr v-for="currency in currencies" v-bind:key="currency.Name"> <td class="uk-width-medium">{{currency.Enabled}}</ ...

Passing inline CSS styles from parent component to child component in Vue

I am currently using vue.js with vuetify, and I need to position a button on top of a canvas component (managed by the Konva library). I successfully achieved this by using absolute positioning for the button. However, in order to organize my code better, ...

The HTML textarea is not updating properly when using jQuery's keypress event

I am facing an issue with my forms on a webpage, each containing an html textarea: <textarea name="Comment" class="inputTextArea">Hello World!</textarea> There is a javascript event handler that automatically submits the fo ...

Issue with Jdenticon icons not displaying correctly in ng-repeat loop

Recently, I started using the Jdenticon JavaScript library for generating user icons. This library allows me to input a hash and then render it as either SVG or Canvas. Here is an example code snippet: <svg width="200" height="200" data-jdenticon-has ...

Error encountered when trying to launch Firefox browser using Selenium and Python: "selenium.common.exceptions.WebDriverException: Message: connection refused"

I have been attempting to execute this code block: from selenium import webdriver browser = webdriver.Firefox() browser.get('http://seleniumhq.org/') Upon running the code, Firefox opens but fails to navigate to the specified link. Instead, I ...

Attach the keyboard to the screen in a fixed position

How can I keep the keyboard always visible on the screen? The screen contains: one TextInput (multiline) two FlatList Typing in the TextInput is fine, but when interacting with the FlatList, the keyboard disappears. I want the keyboard to remain visib ...

What is causing the malfunction in jQuery version 1.7.x?

Here is a code snippet demonstrating the issue I am facing: var $div = $('<div>'); $('span').live('click', function() { this.innerHTML = 'changed'; }); $div.append( $('<span>span</span>& ...

What is the reason that the ES6 module import expression fails to import JSON files located in the assets folder when using certain path arguments?

A puzzling ES6 import scenario came up where the following import statement did not function as expected within methods of a Vue.js SFC: const fullContentFile = '@/assets/rules/rules.json' import(fullContentFile).then(data => console.log(&apos ...

Mastering Protractor's end-to-end control flow and managing time outs

When testing an angular app using protractor, I encountered a strange issue recently. Every now and then, or since a recent update, protractor seems to stall or slow down significantly. After investigating the problem, I discovered that a simple someEleme ...

JS if clause fails to return true as expected

Here is my setup: <div id="user_input">...</div> And a button: <input type="button" id="panel_button">...</button> Using a selector: function $(id) { return document.querySelector(id); } With an event handler: var button_ ...

Cross-origin resource sharing policy is preventing a request from the client-side to the server

I am currently working on a Vue.js application and I am facing an issue with CORS policy blocking my backend requests. I am using axios to make the request to the backend for data that I need to display charts on the UI. Here is the code snippet of my char ...

Issues encountered with JSON formatting following jQuery ajax request

When my nodejs app receives data from a cordova app through a jQuery ajax call, the format is different. It looks like this: { "network[msisdn]": "+254738XXXXXX", "network[country]": "ke", "network[roaming]": "false", "network[simSt ...

The functionality of setTimeout in Chrome extension is malfunctioning

Greetings everyone, this is my first post here! I'm currently working on a chrome extension where I am utilizing a recursive setTimeout function. Interestingly, I've noticed that setting the timeout to 13 seconds works fine, but anything beyond ...

Ensure the Firebase real-time database in Javascript purges the active session upon tab or browser closure

I need to implement a feature in my Firebase real-time database project using JavaScript where the current session is logged out automatically after closing the tab or browser. When I log in with my email and password, if I copy the URL and paste it into ...

Using SeleniumBasic VBA to open Edge browser in IE compatibility mode

Encountering difficulty when attempting to launch a URL in an Edge Browser using SeleniumBasic for VBA. The issue stems from the fact that the secure website has two specific requirements that must be met. Firstly, the SeleniumBasic-controlled website ne ...

Krajee Bootstrap File Input, receiving AJAX success notification

I am currently utilizing the Krajee Bootstrap File Input plugin to facilitate an upload through an AJAX call. For more information on the AJAX section of the Krajee plugin, please visit: Krajee plugin AJAX The JavaScript and PHP (CodeIgniter) code snippe ...

Launching URLs from JSON data in the system browser - Apache Cordova

I am facing an issue with opening links from a JSON in the system browser on both Android and iOS devices. The link generated by the function appears as: {{item.addressLink}}, instead of bit.ly/xyzxyz Here is what I currently have: <a href="#" ng-cl ...