Troubleshooting Selenium Error on Extjs Website

Currently, I am conducting a test on an Extjs application using selenium and facing the challenge of setting the value of a combo box through a script. My attempt involved using the getEval command with the target:

var combo=Ext.getCmp('combobox name'); combo.setValue('4'); combo.fireEvent('select');

Unfortunately, this resulted in the following error message:

[error] Threw an exception: Ext is not defined

If anyone has any suggestions or solutions, please feel free to assist. Thank you!

Answer №1

Did you consider using jsExecutor?

    JavascriptExecutor js = (JavascriptExecutor) driver;
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("var combo=Ext.getCmp('combobox name');");
    stringBuilder.append("combo.setValue('4');");
    stringBuilder.append("combo.fireEvent('select');");
    js.executeScript(stringBuilder.toString());

If any other exceptions are thrown, try debugging step by step in your IDE.

You may also find helpful information here under the Executing JavaScript from Your Test section:

JavaScript can be very useful for testing applications not directly supported by selenium. The getEval method of the selenium API can execute JavaScript from selenium RC.

public static String[] getAllCheckboxIds () {
             String script = "var inputId  = new Array();";// Create array in java script.
             script += "var cnt = 0;"; // Counter for check box ids.
             script += "var inputFields  = new Array();"; // Create array in java script.
             script += "inputFields = window.document.getElementsByTagName('input');"; // Collect input elements.
             script += "for(var i=0; i<inputFields.length; i++) {"; // Loop through the collected elements.
             script += "if(inputFields[i].id !=null " +
             "&& inputFields[i].id !='undefined' " +
             "&& inputFields[i].getAttribute('type') == 'checkbox') {"; // If input field is of type check box and input id is not null.
             script += "inputId[cnt]=inputFields[i].id ;" + // Save check box id to inputId array.
             "cnt++;" + // increment the counter.
             "}" + // end of if.
             "}"; // end of for.
             script += "inputId.toString();" ;// Convert array in to string.
             String[] checkboxIds = selenium.getEval(script).split(","); // Split the string.
             return checkboxIds;
 }

Here's another example:

selenium.getEval("window.document.images.length;");

I hope this information is helpful to 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

Expanding the current module definition: A step-by-step guide

I have created a declaration file for an existing npm package, but it seems like one method was not declared. I attempted to add it, but encountered an error. Can someone please assist me? Here is the structure of the existing d.ts file: declare modul ...

The rotation of Google Maps always returns to its default position when I open the map information window by clicking on it

I have successfully implemented a Google Map with tilt and heading functionality, allowing the map to rotate horizontally. However, I am facing an issue where clicking on a marker resets the map back to its original position. You can view the map by follo ...

Obtaining a file using capybara independently of rails

Case Study: Attempting to access an external URL using Capybara for downloading a file. It is necessary to use Selenium or Webkit as the driver, since Rack-test does not allow visiting external URLs. This website utilizes iframes. The prompt for file dow ...

Revitalize JustGage using jQuery

I made a mistake while using jquery to refresh my JustGage gauges. The data from the controller is retrieved successfully, but unfortunately, I encountered an issue where the computer eventually runs out of memory and freezes. With 9 gauges and 2 pie chart ...

How can I automatically center a Vimeo iframe vertically without having to manually adjust the position?

I'm trying to adjust a popular fluid jQuery script so that it can automatically center a vimeo video vertically, without any black bars. A little horizontal cropping is acceptable. Here is my current code: HTML <div class="container"> < ...

The smartcard node encounters an SCardConnect error when attempting to scan the card, followed by an SCardListReaders error upon disconnect

I am currently utilizing both angular and electron, and everything was functioning properly in the past. However, I am now encountering this error: Error: SCardConnect error: SCardConnect error: The smart card cannot be accessed because of other connecti ...

Error message "Invalid selector: unable to choose date format from the dropdown list" encountered while trying to

When testing an application, I am trying to select a date format from a drop-down list. The specific date format I need is dd/mm/yyyy (displayed in the dropdown). However, I encounter an error when attempting to choose this option: Selenium::WebDrive ...

Fetching the value of a hiddenField in ASP.NET by utilizing the ClientID attribute while working with master pages and

While working with master pages in .NET, I encountered an issue where I couldn't retrieve values using ID's because .NET automatically adds its own id values. To learn more about this problem, check out a helpful article called Can't get JQue ...

An unexpected issue occurred: Unable to invoke method on NPObject

I am new to JSON and having trouble accessing object data. Here is the code snippet: <!doctype html> <html> <head> <meta charset="utf-8"> <title>ajax </title> </head> <body> <p id="p"></p& ...

The type 'void | Observable<User>' does not include the property 'subscribe'. Error code: ts(2339)

authenticate() { this.auth.authenticate(this.username, this.password).subscribe((_: any) => { this.router.navigateByUrl('dashboard', {replaceUrl: true}); }); } I'm puzzled by this error message, I've tried a few solu ...

Retrieve the Latest Information from the Asp.Table

My table setup is as follows: <asp:Table ID="model" runat='server'> <asp:TableRow> <asp:TableHeaderCell class="col-xs-2"> Name </asp:TableHeaderCell> <asp:TableHeaderCell class="col- ...

Navigating through the content of slots within recurring slots in a subcomponent in Vue.js

I am encountering an issue with a child component, where each row in an object is rendered inside a div with a specific slot. I need to pass data from the parent for each of these elements. I've been attempting to iterate through every element of the ...

Learn how to dynamically swap background images in Vue.js when hovering over different elements

I am facing an issue where I need to change a background image upon hovering over four different elements, with one unique image for each element. Here is what I have attempted: HTML: <div class="projects"> <a v-on:mouseover="hover=myimage1" ...

Displaying only the navigation controls of Bootstrap 5 Carousel without the actual content

Currently, I am in the process of building an HTML website and incorporating the bootstrap 5 framework into it. My main objective is to integrate a bootstrap 5 Carousel within a section of the website alongside an image, as demonstrated in the following i ...

Enhance your coding experience with Firebase Autocomplete on VScode

Recently, I installed VScode along with the necessary packages for JavaScript development. As I started writing code involving Firebase, I noticed that the autocomplete feature, which worked perfectly fine in Xcode, was not functioning in VScode. How can I ...

Unable to retrieve the page source/DOM from a websocket endpoint set to self-refresh

Experience a website that automatically updates with more text data. When using Chrome, attempting to view the page source may result in a blank page indefinitely. To bypass this issue, I typically utilize the Inspect tool to access the source. Despite my ...

Struggling to conceal HTML element

I have been attempting to hide or completely conceal certain fields within the item class using jQuery, JavaScript, and HTML, however, the outcome has not been satisfactory. <div class="item"> <label for="id_mobile_number&qu ...

Manipulating the flow of execution in Javascript/jQuery without the use of ajax or php

After spending countless hours browsing various websites, I am still struggling to grasp the concept of controlling execution order in Javascript/jQuery. My goal is to develop code that visually displays the progress of hidden javascript functions on a we ...

mastering the nuances of jQuery event namespaces

Below are some code snippets to consider: $("#atc-button").bind("click.hctpAttach", function (e) { console.log("Add to cart button clicked.") }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> ...

consolidating express routes in one consolidated file

I am attempting to consolidate routes into a single file using app.use app.js import express from 'express' import testRouter from 'testRouter' const app = express() app.use('/testRouter', testRouter) app.listen(3000) tes ...