Is it possible for Selenium to interact with buttons from the LightSwitch library?

Is it possible for Selenium to interact with LightSwitch buttons?

In my initial attempt, I had to locate a button styled using LightSwitch in CSS. I used By.CSSSelector to find the button. However, upon locating the button, I realized that it was utilizing the vclick event from the JQuery library.

Subsequently, I wrote the following code:

js.ExecuteScript("$('.ui-page-active .msls-footer div div:nth-child(2) span').trigger('vclick')");

Despite successfully locating the button using Selenium, it seems like the button is not being clicked. What could I be missing here?

Additionally, even though the test passes without any errors, no new window is opened after clicking the button.

The expected behavior is for the application to switch screens upon clicking the button, but unfortunately, this transition does not occur as intended.

Location of the button on screen:

Expected screen after clicking the button:

Answer №1

Here's a better approach to using WebDriverWait instead of relying on Thread.Sleep():

IWebElement element = (IWebElement)js.ExecuteScript("return $ ('.ui-page-active .msls-footer div div:nth-child(2)')[0]");

WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(20));
wait.Until(ExpectedConditions.ElementToBeClickable(element)).Click();

Give it a try and see if it works for you! 😊

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

What is the best way to search a map object that serves as the document ID in Firebase?

I am attempting to retrieve all fieldnames within the payload > (random doc id) objects. https://i.sstatic.net/y9703.png At this moment, my approach involves fetching other collections using the following code: async fetchPage() { const query = fir ...

The response from Moment.js shows the date as "December 31, 1969."

Currently, I am in the process of recreating one of FCC's backend projects: Upon testing my code, I noticed that when I input the following URL: http://localhost:3000/1 The result is as follows: {"unix":"1","natural":"December 31, 1969"} var e ...

Tips for ensuring that one table column matches the width of another column

Is there a way to allow column 3 in my dynamically populated table to have a flexible width while enforcing that column 4 matches the width of column 3? ...

Timeout function not being triggered for mousedown or touchstart event handlers

Fiddle - http://jsbin.com/AYeFEHi/1/edit Could someone help troubleshoot why this code is not functioning as expected? (I am using Chromium on a Linux system) The goal is to trigger the alert box only after holding down the button for 2 seconds, and if r ...

Debug mode in React Native using hooks may encounter discrepancies in data stored in AsyncStorage

I am working on a project where I have two separate screens connected with a simple react native stack router. The second screen contains choice blocks that set state using useState and AsyncStorage. Every time the screen is entered, it reads the state of ...

API response in NodeJS encounters failure following fs.writefile operation

A new API has been developed to create a file and then request a log API after the file is written. The response will be sent back to the user based on the log API response. Here is a simplified version of the code: const express = require('express&a ...

How can I incorporate percentage values into input text in Angular?

How can I include a percent sign in an input field using Angular, without relying on jQuery? I am looking for a solution that is identical to what I would achieve with jQuery. Here is the current status of my project: ...

What is the best way to update objects in different scopes within AngularJS?

Exploring AngularJS for the first time, I find myself struggling with understanding scopes. My current dilemma involves modifying an object or variable from multiple scopes. Here's the scenario: I'm looking to centralize the user notification Co ...

Executing tests in parallel using SpecFlow across a single or multiple test agents

Is it possible to run SpecFlow test cases in parallel on the same test agent using MS Test? ...

When attempting to add an image to a table, I struggle to do so without disrupting the alignment of the surrounding cells

I'm having an issue with adding an image to my table. Whenever I place the img tag between the <td> tags, the content in the neighboring cell behaves as if there are <br> tags above it. I attempted to use display:inline-block, but it had ...

Let's implement a sleek "load more" feature for your ASP.NET repeater just

Hey there, I was wondering if anyone has any cool samples of how to implement a Twitter-style load more items feature. How can I accomplish this using an ASP.NET repeater? ...

Implement a system in Angular Service that automatically generates user IDs for an array of user inputs

How can I automatically increment the user ID for each new user input and use that value for deletion or updating of specific entries? If a user adds their details as shown in the output picture link below, I want to display the output in a similar format ...

javascript extract data from JSON

How can I extract values from the [object Object] in javascript? I have a JSON response from PHP that I am passing into JavaScript. I want to retrieve the GPSPoint_lat and GPSPoint_lon values. var jArray = ; var obj = JSON.parse(jArray); I am gett ...

What is the best way to verify that the unobtrusive validations have been successfully validated within a jQuery function?

Currently, I have a form containing four fields with unobtrusive validations applied to three of them. My goal is to call a jQuery function only after all the unobtrusive validations have been successfully completed. However, I have defined an onsubmit eve ...

Running queries in a loop is not functional within node-firebird

When running multiple select queries in a loop, I encountered an issue that puzzled me. For simplicity, let's take a look at the code snippet below: var Firebird = require('node-firebird'); Firebird.attach({database: 'TEST'}, (e ...

What is the best way to create a repeating Jquery loop in code?

Hey there! I've been working on creating a button that toggles the background color from white to yellow and back again using Jquery. However, I've hit a bit of a roadblock with implementing a loop function. If you'd like to take a look at m ...

displaying the outcome of the extended project in Ajax

I am currently working with a Java class that contains various functions. Each function is responsible for printing its result either in the console or on a web page, depending on how it was initiated. The structure of my class looks something like this: ...

What is causing my vue.js table to not display properly?

Struggling to render a table using vue.js? You're not alone. Many developers face challenges when trying to use v-for to iterate through data and display it in a table format. It can be frustrating when everything seems fine in the console, but the ta ...

Is there a way to determine if a React functional component has been displayed in the code?

Currently, I am working on implementing logging to track the time it takes for a functional component in React to render. My main challenge is determining when the rendering of the component is complete and visible to the user on the front end. I believe t ...

Sending a form cancellation submission within a nested function call

I need help preventing my form from submitting in case the confirmation message is cancelled. How can I achieve this within the each() loop? $('#myForm').submit(function() { var inputs = $(this).find('input:checked'); inputs.ea ...