I am facing issues with the executeJavaScript() function in htmlunit. It seems to be

Trying to log in using a JavaScript command, but even after using executeJavaScript(), the previous page content continues to display. The

checkLogin(9143088043,123456,-1,false)
command should connect to a new page.

         final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
         final HtmlPage page1 = webClient.getPage("http://10.254.1.4:90/login.aspx?tt=1");

         String javaScriptCode = "checkLogin(9143088043,123456,-1,false);";


         ScriptResult r= page1.executeJavaScript(javaScriptCode);

         HtmlPage page2=(HtmlPage) r.getNewPage();

         System.out.println(page2.getWebResponse().getContentAsString()); //prints the last page content

This error message is shown:

run:
Oct 29, 2015 2:45:16 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'application/x-javascript'.
Oct 29, 2015 2:45:17 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: *:x).] sourceName=[http://10.254.1.4:90/Script/jquery-1.10.2.min.js] line=[4] lineSource=[null] lineOffset=[0]
... 
BUILD STOPPED (total time: 19 seconds)

Answer №1

Here's a solution to eliminate logs using HtmlUnit:

LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");

java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); 
java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);

client = new WebClient(BrowserVersion.FIREFOX_38);
client.getOptions().setJavaScriptEnabled(true);
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setThrowExceptionOnFailingStatusCode(false);

//(insert your code here)

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

There was a parsing error in react.js: An unexpected token was encountered, when a comma was expected

When working in react.js, I encountered the following error: function Sidebar() { const [rooms, setRooms] = useState( [] ); useEffect(() => { db.collection("rooms").onSnapshot((snapshot) => ...

Integrating an API with a Discord bot using an embedded link in Discord.js

I am currently in the process of creating a bot that can generate and embed links to display manga titles, tags, and other information based on user-input digits. I have been exploring an API called this and I am eager to learn the most effective method ...

Notification: failed to register service worker for messaging

An issue arose during the retrieval of the token. FirebaseError: Messaging: The default service worker registration failed. Failed to register a ServiceWorker for scope http://localhost:3000/firebase-cloud-messaging-push-scopewith script http://localhost ...

The benefits of installing gulp plugins locally versus globally

Being a newcomer to Gulp, I have a query: should I install gulp plugins (like gulp-sass or gulp-imagemin) locally or globally? Most online examples suggest installing them locally using the --save-dev option. This method saves the modules in the local node ...

When attempting to pass data to a modal, an error occurs due to props being undefined. This results in a TypeError with the message "Cannot

I'm working on a product listing feature where each item displays some information along with a "more details" button. When the button is clicked, a modal window opens to show additional details of the specific product (using props to pass data betwee ...

Timestamped console output in Eclipse

Currently working with Selenium webdriver scripts in Eclipse, and I am looking for ways to display console output with timestamps. Even though I am utilizing the log4j framework for application logging, my client specifically requires console output with t ...

Guide on making a submit and close button within an overlay

Seeking a button to both submit and close an overlay window. The button code is as follows: <a href="javascript:additem('Info to add here', 10.00,1);" role="button"><button class="purchase btn btn-warning">Select</button></ ...

Ways to delete the title from a box in orgChart

Is there a way to remove the title from the box and only show the content? I've searched extensively but haven't found a solution yet. I'm currently using orgChart: https://github.com/dabeng/OrgChart For example, the general manager box s ...

Tips for customizing the font color in Material UI Typography

Is it possible to change the color of only this text to red? return <Typography style={{ color: 'red' }}>Login Invalid</Typography> I came across this online solution, but I am unsure how to implement it as there is no theme={color ...

How can you utilize data captured through a JavaScript onchange event in conjunction with another event?

Is there a way to utilize the firmType data captured during event 1 in event 2? code event 1 $("body").on("change","#so_customer", function(v){ customerFirm = $(this).find(":selected").data("employer"); $("#customer_employer").val(cust ...

What is the best approach for managing a drop-down menu in Protractor test automation?

I am a beginner with this tool and have experience handling drop down menus in Selenium WebDriver. Can anyone provide guidance on how to handle drop down menus using the Protractor tool? Any tips, tech forums recommendations would be greatly appreciated. ...

Can you provide guidance on displaying flash messages in my template using Express.js?

app.get('/',function(req,res){ res.render('home'); // Ensure the template has access to the flash message }); app.get('/go',function(req,res){ req.flash("info", "You have gone to GO and got redirected back home!"); ...

What is the reason why sinon stub is unable to replace the actual exports.function?

I have a situation where my controller async function is calling another async exported function. I am looking to test specific results of the dependent function rather than testing the dependency itself. However, when I try to stub the function, it seems ...

JBehave context devoid of any content

Utilizing both Serenity and JBehave for a single test suite, I am attempting to retrieve the current story and scenario names for BrowserStack video naming purposes. According to the official documentation, I should use ContextView for this task. I found t ...

Retrieve information using the request npm package

Currently, I am in the process of developing an application with express js. My approach involves using request(v-2.88.2) to retrieve data from an api. request(url, function(error, request, body) { var data = JSON.parse(body); }); My goal is to utili ...

Ways to insert HTML text into an external webpage's div element without using an iframe

Is it possible to generate HTML and SVG code based on the position of a Subscriber on a web page or within a specific div? I would like to provide some JavaScript code that can be inserted inside a particular div on the page. Using an iframe is not ideal ...

Angular's implementing Controller as an ES6 Class: "The ***Controller argument is invalid; it should be a function but is undefined."

Struggling to create a simple Angular todo application using ES6. Despite the controller being registered correctly, I keep encountering an error related to the title when navigating to the associated state. *Note: App.js referenced in index is the Babel ...

utilizing a single configuration to operate multiple instances of ehcache concurrently on a single server

Currently, I am working on setting up a replicated ehcache configuration that can function over both a local network and on the same machine. Below is my current configuration: <?xml version="1.0" encoding="UTF-8"?> <diskStore path="java.io.tm ...

What is the reason for the automatic loading of coffee files in app/assets/javascripts across all files?

I have a question about organizing my Javascript files in my app. I have multiple files in the app/assets/javascripts folder, and for testing, I have written some code in a file named test.coffee: $ -> $(document).ready -> alert("Hey"); When ...

gulp-open not functioning properly following the use of createWriteStream

I am utilizing gulp, gulp-eslint, and gulp-open to generate a report detailing ESLint outcomes. The linting and file creation processes function correctly; however, the task aimed at opening the file containing my report encounters issues. gulp.task(&apos ...