Automated Form Submission using Selenium

Trying to automate form submission with selenium, but encountering JavaScript issues causing exceptions. Instead of directing submit to the form action, Selenium is redirecting it to localhost. Any help on why this is happening and how to fix it?

Here's the form:

<!DOCTYPE html>  
<html lang="en" dir="ltr">
...
</html>

Java Code:

private final static String PF_BASE_URL = "https://machine.place.domain.com";
...

Stacktrace:

Exception in thread "main" org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: Exception invoking submit
...

Answer №1

According to information from the Selenium documentation:

Mainstream browsers do not utilize the javascript engine employed by HtmlUnit (Rhino). Hence, testing javascript with HtmlUnit may produce different results compared to traditional browsers.

To put it simply: if your application heavily relies on JavaScript functionality, it is advisable to avoid using HtmlUnit. For a headless browser alternative, one can explore options like PhantomJS.

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

Refreshing MongoDB data by utilizing values from an object

I am facing a challenge with my MongoDB collection structure: [ { "stock": "GOOGLE", "price": 0 }, { "stock": "FACEBOOK", "price": 0 } ] On the other hand, I have a Stock_P ...

Discover the best way to implement Wait.Until in Selenium when you already have the element using FindsBy

Currently, I am utilizing the Wait.Until method to ascertain whether my page has finished loading or if it is still in the process of loading. The implementation looks like this: protected IWebElement FindElement(By by, int timeoutInSeconds) { ...

What is the best way to use JavaScript to replace &amp;#8364; with &#8364;?

Currently, I am in the process of troubleshooting an issue with a forum where HTML entities are not being displayed correctly. Unfortunately, the owner of the forum is missing in action, so I am attempting to address this using a browser extension. Here&a ...

What causes the React white screen of death to disappear when this code is commented out?

Currently, I am working on a React application that pulls trivia questions and answers from an API to create a game interface. Everything has been going smoothly with the development process until I imported a decode function to properly display the trivi ...

Breaking down an array into function arguments in TypeScript/JavaScript

I am working with an array of object instances that have different types. var instances: any = []; instances["Object1"] = new TypeA(); instances["ObjectB"] = new TypeB(); Each type has its own methods with unique names and varying numbers of arguments. I ...

Attempting to retrieve user input and retrieve the file extension

Currently, I am attempting to capture user input that contains a file extension such as .txt or .html. However, I am uncertain if Java supports String slicing similar to Python. Can someone guide me on how to accomplish this task? My goal is to grasp the ...

I need to verify the format yyyy-mm-dd hh:mm using a regex pattern

Trying to create a validation pattern for date and time in the format: YYYY-MM-DD hh:mm (Date time) led me to the following regex: "regex": /^((((19|[2-9]\d)\d{2})[\/\.-](0[13578]|1[02])[\/\.-](0[1-9]|[12]\d|3[01])\ ...

Arrays causing Typescript compilation errors

There are a pair of typescript documents: one file as a module that implements the Client class export class Client { the other file as the main document that imports the module and generates an array of clients import c = module("client ...

Another way to encode a string to base64 in Node.js without relying on the Buffer module

While utilizing Buffer in one of the cloud functions to convert a string into Base64 encoding, I have encountered a delay of 15 seconds during bulk processing. Buffer.from(JSON.stringify(msgBody)).toString('base64')) I am exploring alternative m ...

Retrieve information from data properties in the Froala editor

I'm currently developing a custom toolbar button for Froala Editor. To execute my desired action, I require access to a data attribute stored within the original textarea. Is there a recommended method for accomplishing this task? Appreciate your as ...

Hold off on executing two tasks - selenium using Java

I am attempting to utilize Fluent wait for performing two specific actions: Clicking on the search button Verifying the result for a particular element Currently, I am using the following code snippet but it does not seem to be functioning as expected: ...

Steps to resolve org.json.JSONException: Index 2 out of bounds [0..2) error

I am encountering an error when trying to retrieve data from the following JSON in my API response: {"success":true,"id":"4","name":"VOUCHER GOOGLE PLAY","data":[{"id":10,"product_id":"GLP","product_name":"GOOGLE PLAY","prefix":null,"pembeliankategori_id" ...

Ways to activate the enter key

Here we have the input bar and search button setup in our HTML code: <div> <div class="input-group search-bar"> <input type="text" class="form-control search-box" placeholder="Search people" autofocus="" ng-model="searchPeople"& ...

Tips for choosing a particular certificate in Selenium using Python

I seem to be facing an issue when trying to select a certificate using Selenium in Python. I attempted to treat it as an alert, but unfortunately, I was unsuccessful. Could someone possibly provide assistance? Here is an example. Below are the settings f ...

What is the best way to retrieve state within a property of a React class component?

I have encountered an issue with a React Class Component where I am trying to separate a part of the rendered JSX but unable to access the Component's state within the separated JSX as a property of the class. The scenario is quite similar to the fol ...

Issue encountered while trying to install Yeoman on Yosemite

I've been attempting for days to install Yeoman on my OS X, but I'm having no luck =/ Every time I try to install it, I encounter this error: Mac-Pro:~ pauloricardo$ sudo npm i -g yo Password: > <a href="/cdn-cgi/l/email-protection" clas ...

The radio button allows for the selection of multiple items, rather than just one at a time

https://i.sstatic.net/9MEzS.png I have implemented a radio input as shown below <input type="radio" id={el.name} className="form-check-input" name={el.name} data-count={el.name} value={el.id} onChange={this.select_role.bind(this)} style={{margin: "4px ...

Numeric Input Box: Show gaps

I have numeric input boxes in my HTML/PHP/JS application where users will be entering numbers with 4 to 7 digits. However, I want the users to see spaces between every third digit for better readability. For instance, User types: 8000 Us ...

Protractor - Resolving as pending promise when executed

I have been working on creating a function that can search through an array of elements and return the first element that meets certain criteria. Here is my test code that works as expected: element.all(by.css('_cssSelector_')).filter(function( ...

Is AngularJS the right choice for developing this application?

Recently, I've come to the realization that I want to dive into the world of AngularJS framework after working with jQuery for several years. I have a vision of developing an application that allows users to easily modify webpage DOM using a browser- ...