Determine the quantity of tabs present in a tabset created through ng-repeat using Selenium automation

Currently conducting testing on a webpage that features multiple tabs grouped within a tabset created using ng-repeat.

The tabs are dynamically generated by the following code snippet:

<tabset id="tabset">
    <tab ng-repeat="server in servers">
        <tab-heading>{{server.name}}</tab-heading>
        <div>{{server.body}}</div>
    </tab>
</tabset>

My current testing approach involves:

@Test
public void shouldDisplayAtLeastOneServer() {
    Assert.assertThat(webDriver.findElement(By.id("tabset"))
            .findElements(By.tagName("tab"))
            .size(), Matchers.greaterThan(0));
}

However, this test is failing as the size returned is 0 despite knowing that there are 4 visible tabs.

Answer №1

Angular has completely revamped the code structure!

It's like magic:

<tabset id="tabset"> is now <div id="tabset" ...> and

<ul class="nav nav-tab" ...>

<tab> has transformed into <li ...>

This transformation has been successful:

@Test
public void shouldDisplayAtLeastOneServer() {
Assert.assertThat(webDriver.findElement(By.id("tabset"))
        .findElement(By.tagName("ul"))
        .findElements(By.tagName("li"))
        .size(), Matchers.greaterThan(0));
} 

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

Include the entirety of selenium-webdriver by importing all of its files

It may sound strange, but I have a unique idea for importing the Selenium-Webdriver module. Instead of importing it using the usual method: from selenium import webdriver I want to import each file of the module separately like this: import C:\sele ...

Dynamic stacking of buttons in response to user navigation choices

Is it possible to create a navigation bar with 5 buttons using CSS and JS? Here is what I am looking to achieve: Display 5 nav/button options When a user clicks on a button, the other buttons should transition or hide, leaving only the selected button vi ...

Troubleshooting ngFor in Angular 5

I'm currently working on a component that needs to display data fetched from the server. export class CommerceComponent implements OnInit { dealList; ngOnInit() { this.getDeals(); } getDeals(){ this.gatewayService.se ...

Exploring the differences between io.emit and socket.emit

Having just delved into the world of socket.io, I've come across something that's puzzling me. I'm unclear on the distinction between socket.emit and io.emit, and my search for a clear explanation has turned up empty. io.on('connection ...

Toggle the visibility of fields using dynamic identifiers (NodeJS, Mongoose, Express, JavaScript)

I am using a forEach loop to display menus for various restaurants when the restaurant icon is clicked. The number of restaurants/menus and their icons are unknown, each created with a dynamic ID such as menu-0, menu-1, menu-2, and so on. When one restaur ...

Is it permissible to use multiple JWT tokens in the HTTP header?

Currently, I have implemented the jwt access and refresh token pattern for client-server communication. The method involves sending two jwt tokens in the header: the access token and the refresh token. This is done by adding the following code to the heade ...

Exporting an imported obj with Draco compression in Three.js

My javascript skills are limited, but I can get basic things working in threejs. Currently, I am struggling with the Draco exporter. The Threejs.org website has an example of the Draco exporter This example demonstrates exporting a generated mesh and it ...

Obtain an array containing only the specific values of each object

Currently, I have the following code snippet: <db.collection>.find({ id : { $exists: true } }) This query retrieves all documents containing an id property. However, I am interested in transforming this result into an array that contains only the va ...

Accept JSON data in ASP.NET MVC action method for posting data

I have a model class named Parcel which contains the parameters Name and CenterPoint: public class Parcel { public string Name { get; set; } public object CenterPoint { get; set; } } The values for these parameters are obtained from a map. When a ...

Tips for updating the state in React once all the fetch requests inside a loop have been successfully completed

Currently, I am working on a React application where I am facing an issue with setState in my App. I want to set the state only after all the AJAX fetches have been resolved to prevent multiple unnecessary re-rendering. Here is what I have attempted so fa ...

Retrieve value from array input

Is there a way to extract input text values from an array using JavaScript? Here is the code snippet: Item : <input id="t_item" name="t_item[]" type="text" class="teks3"> Cost : <input id="t_cost" name="t_cost[]" type="text" class="teks3"> &l ...

Is there a way to eliminate specific words from an array?

Given an array of words, how can I extract all the words that have more than three characters and store them in a new list? public class WordExtractor { public static int counter; public static int index=0; public static void main(String[] ...

Understanding special characters within a URL

Here is a URL example: postgres://someuser:pas#%w#@rd-some-db.cgosdsd8op.us-east-1.rds.amazonaws.com:5432 This URL is being parsed using the following code snippet: const url = require('url'); const { hostname: host, port, auth, path } = url.par ...

Checking variable length time with JavaScript Regular Expression

My specific requirement is to validate a string ranging from 1 to 4 characters in length (where H stands for hour and M represents minutes): If the string has 1 character, it should be in the format of H (a digit between 0-9). A 2-character string should ...

When creating a new instance of java.net.Socket, an exception is thrown if using the 4-parameter version of the constructor, but not

While experimenting with sockets, I encountered an interesting issue. The following program: public class TestSocket { private static final String remoteHost = "gmail-smtp-in.l.google.com"; private static final int port = 25; public static v ...

Appium's implicit wait feature seems to be having trouble functioning properly

Having trouble with Appium while automating an iOS app. Has anyone encountered this issue before? The implicitlyWait API in Appium doesn't seem to be working for me. I'm using Java and JUnit for running the test, and here's the line of code ...

Is there a way to display the JavaScript widget exclusively on the homepage or main page

How can I limit the display of a Twitter widget on my blog page to only show on the main page and hide it when visitors navigate to sub-pages or individual blog entries? ...

Why is my Typescript event preventDefault function ineffective?

Despite all my efforts, I am still unable to prevent the following a tag from refreshing the page every time it's clicked. <p> <a onClick={(e) => handleClick} href="&qu ...

Glitch in the system: Customizing buttons with Google Maps API v3

With my custom buttons on Google Maps, I am able to create markers with different icons for each button. However, when I click on one button to create a marker and then click on another button to create another marker, the two buttons end up overlapping ea ...

Having trouble running Javascript with jQuery's ajax load()?

I have encountered this problem and despite reading multiple posts, I am unable to find a solution. My challenge lies in loading an HTML file into a div that contains an unordered list. The list is supposed to function as an expanded menu with sub-items, ...