I'm struggling to locate the target for the WaitTextForPresent command in Selenium IDE when testing an AJAX website. Can anyone offer

As a newcomer to JavaScript, Selenium IDE, and web development, I am currently learning about a website that uses an AJAX application at . I am trying to utilize the WaitTextForPresent command to detect when a unique chat message appears, but I am unsure of where to apply the command. Can anyone provide some guidance?

[update]

    <div id="logbox" class="logbox">
        -many other <div id= >
        <div class="logitem"></div>
        <div class="logitem">
            <div class="strangermsg">
                <span class="msgsource"> Teman Kamu: </span>

                F

            </div>
        </div>
    </div>

I have attempted various approaches such as AssertForElement and AssertVisible, but I have not achieved satisfactory results. My primary issue lies in pinpointing the exact target for these commands.

The most promising command I have tried thus far is

<tr>
    <td>assertText</td>
    <td>css=div.strangermsg</td>
    <td>F</td>
</tr>

And The Result:

[error] Actual value 'Teman Kamu: F?' did not match 'F'

While it is close to the desired outcome, I aim to isolate only the text message 'F' without the preceding span class 'Teman Kamu: ' (which translates to 'Stranger' in English).

Thank you

Answer №1

If you are working with junit tests, you might want to consider implementing something along these lines:

WebElement message;
  for(int i = 1; i < 100; i++)
     message = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='logbox']/div[" + i + "]/logitem")));

As of now, I have not come across a better solution for waiting for the next message to appear other than using a for() loop.

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

Struggling with implementing Bootstrap modal JavaScript in Rails 4, nothing seems to work!

This situation has been addressed in numerous posts, but despite my efforts to find a solution among them, I have yet to come across one that works for me. I am faced with the task of opening a modal that requires JavaScript modifications before being dis ...

Encountering a null pointer exception when attempting to declare a WebElementFacade within a page object

While attempting to implement the page object model in Serenity BDD, I encountered a null pointer exception when declaring WebElementFacade in my page object. Below is the code for my page object class: package PageObjects; import net.serenitybdd.core.an ...

Constructing the necessary gulp configuration file

When using Gulp and Gulp-sass, with the use of 'gulp.watch', how can I retrieve the directory name of the modified item on the watchlist in order to compile the sass to css? Currently, the setup only compiles the sass files from theme 1. If ther ...

Tips for achieving comma-separated user input via ngModel and appending it to an array

I am working on an email template that includes a cc option. I want users to be able to add email addresses with commas separating them and then push them to an array called $scope.notifyCtrl.cc. How can I accomplish this using AngularJS 1.5 and above? mai ...

the present time plus a one-hour situation

I am facing a challenge where I need to dynamically adjust the path based on specific time conditions. In this situation, I will be working with two date variables retrieved from an API: CheckInStartDate and CheckInEndDate. The current system date and tim ...

Having trouble managing the popup window with Selenium WebDriver

When using WebDriver, it launches the browser and navigates to the URL of the application. However, when a link is clicked, a pop-up window appears in a new browser tab, preventing any control over the original browser until the pop-up window is closed. T ...

What is the best way to initialize firebase with context in a React application?

Currently, I'm following a tutorial at this link: I've hit a roadblock at the following step: Context.jsx import React from 'react'; const FirebaseContext = React.createContext(null); export default FirebaseContext; index.js impo ...

What could be causing the "Undefned Jquery-ajax" error to pop up

I am struggling with the following code. My goal is to populate values into a dropdown <select> box, but I keep receiving an error of undefined. I have tried switching between Object.keys and Object.values, however, I am still facing the same issue. ...

Attempting to transmit unique symbols using JQuery Ajax to a PHP script

I am using JQuery Ajax to send special characters to a PHP file. sending_special_characters.js var special_chars = '!@#$%^&*()_+-='; var dataToSend = 'data=' + special_chars; $.ajax({ type: "POST", ...

Angular filter is designed to search for elements that contain a specific value, rather than only those that are an exact match

I am currently trying to relate rules to fields using the 'filter' filter in Angular. You can see an example of this implementation here: http://plnkr.co/edit/dQiv5lRzhQNjXZ6pVdWO?p=preview The code I am using for this purpose is as follows: &l ...

Adding videos to a webpage based on the keywords clicked

Looking to create an exciting application using PHP and MySQL. Currently, I am in the process of querying the database for specific words stored in a table called "words". These words will be used to populate a list on the webpage that will be visible to u ...

Why is the response undefined when I resize an image twice using a JavaScript promise chain?

When I attempt to resize an image using the sharp library twice in my route handler, the result returned is undefined. Despite the resized images being displayed, it seems that calling image.resize and .toBuffer() multiple times is causing corruption in th ...

The anchor tag is not being used in the function call in an Angular application

Having trouble with calling the logout function inside the login controller. The setup involves a simple login and logout system using ui-router. After successfully logging in and navigating to another page, I encountered issues with calling the logout fu ...

Using Scrapy to extract data from Project Euler's website

Currently, I am working on scraping projecteuler.net using Python's scrapy library as a way to practice my skills. While there are existing implementations of similar scrapers online, they seem too complex for my needs. I simply want to save the probl ...

Did the IBM MobileFirst client miss the call to handleFailure?

I am currently utilizing the IBM MFP Web SDK along with the provided code snippet to send challenges and manage responses from the IBM MobileFirst server. Everything functions properly when the server is up and running. However, I have encountered an iss ...

Could this be a memory overflow issue? Utilizing Node.js handlebars partials

heap snapshots I execute the garbage collector before taking each snapshot. During testing with ab, it appears that the memory usage is increasing by 5mb for every 100 requests and does not decrease even after running the GC. It seems like there might be ...

Using Python with Selenium, attempt to click on a button designated as type="button"

I've been trying to click on a button in this Airbnb listing but none of the codes I tried seem to work. Here is one example of the HTML code: <li data-id="page-2" class="_1eqazlr"> <button type="button" class="_1ip5u88" aria-label="Page 2 ...

Is it possible to apply JavaScript object destructuring but make changes to certain values before assigning them to a new object?

After receiving movie data from an api, I am currently manually creating a new object with a subset of properties and modified values. Is there a more efficient way to achieve this using javascript/typescript object destructuring syntax? I specifically wa ...

What is the best way to retrieve a response from a PHP file as an array through Ajax?

Seeking assistance in retrieving a complete address by entering the postal code in an HTML form textbox and clicking a button. The setup involves two files - one containing the ajax function and the other housing the PHP code. Uncertainty looms over whethe ...

Adjust the counter by increasing or decreasing based on the selection or deselection of tags

Currently, I am utilizing Next.js to manage a question form that consists of multiple questions with multiple answers. Users have the option to select one or multiple tags for each question. When a user selects one or more tags to answer a question, it sho ...