Questions tagged [java]

Java, renowned as a cutting-edge, object-oriented programming language, is here to unriddle any enigma perplexing you in its intricate domain. Consider applying this tag when grappling with the essential nuances or comprehending the coding syntax. This label seamlessly aligns with accompanying tags that embrace libraries and frameworks diligently harnessed by skilled Java developers.

Utilizing values from .properties files in Java with Spring for internationalization: A straightforward approach to handle Strings

Here is the code snippet I am using: @Value("${app.user.root}") private String userRoot; This code helps me to fetch a constant value from my application.properties file. Within my GetMapping method, I need to redirect to the error page and pass a S ...

Node.js may not always trigger the 'data' event when a successful POST request is made from a Java program

In my recent project, I encountered an issue with a NodeJs program that receives periodic data from a Java code. The problem is that sometimes only the header of the data makes it through, while other times both the header and the body successfully pass. H ...

I am struggling to get my jquery ajax request to successfully return an XML response

I am encountering an issue with a call: $.get("${pageContext.request.contextPath}/maze/View/${maze}", function(response){drawMaze(response);}); within a JSP file. This call triggers the following Java code: protected ...

Encountering a java.lang.StackOverflowError when executing a class as a TestNG Test in Selenium

This project serves as a demonstration, utilizing the Page Object Pattern and Data-driven framework for implementation. Within this project, concepts of inheritance and constructors are applied. The configuration file config.prpoerties contains details s ...

Can you explain the meaning of arguments[0] and arguments[1] in relation to the executeScript method within the JavascriptExecutor interface in Selenium WebDriver?

When utilizing the executeScript() method from the JavascriptExecutor interface in Selenium WebDriver, what do arguments[0] and arguments[1] signify? Additionally, what is the function of arguments[0] in the following code snippet. javaScriptExecutor.ex ...

Guide to making a 'Put' request using a JSON object towards a JSONPlaceHolder RESTful API in Java

I have a piece of code that retrieves all the data from the JSONPlaceHolder REST API and converts it into an array. Afterwards, I collect input from text fields in my program to create a JSON Object with that information. Now, I want to send this JSON Obje ...

Ensuring the accuracy of selenium XPath expressions

In my Java method, I am trying to create a wait for a specific XPath. If the wait times out, instead of throwing an error, I want to return either null or the element if it is found. To achieve this, I can use try/catch and handle an exception that indicat ...

Is there a way to determine if a specific JSONArray is contained within my existing JSONArray?

I am faced with the challenge of parsing a JSONArray that may or may not include an "attachmentPoint" element. Here is an example of the JSONArray structure: [{"entityClass":"DefaultEntityClass","mac":["86:2b:a2:f1:2b:9c"],"ipv4":["10.0.0.1"],"ipv6":[], ...

What is the process for retrieving user information following REST authentication on the client side?

In my setup, I have a Spring REST backend that communicates with an Angular frontend. For authentication, the frontend sends a POST request to the "/login" URL with the username and password in the request JSON body. The backend responds with an OK code, ...

Encountering problems with storing data containing diacritics in a Java REST API integrated with a MySQL database

I've been working on an app and I'm facing some challenges with handling data that contains diacritics or other UTF-8 characters. The specific characters causing issues for me are: ă-Ă-â-Â-î-Î-ş-Ş-ţ-Ţ. Initially, there is an input fiel ...

Tips on effectively utilizing the generic class type parameter class

One interesting aspect of my work involves a genetic class parameter public static <T> T parse(String json, Class<T> clazz) { T result = null; result = mapper.readValue(json, clazz); return result; } Imagine there is a JSON object l ...

OutOfMemoryError caused by Bitmap

I'm experiencing an issue with this error. I created a favicon parser from URLs using the following code: public class FavIconParser { public static String extractUrl(String url) { StringBuffer sb = new StringBuffer(); Pattern p = Pattern.compile ...

What exactly does the <cbn-root> HTML element signify, and how can it be parsed using Java programming language?

I attempted to develop a Java program to monitor the availability of reserved spots on this website: However, when I examine the page source using Chrome or Edge, only <cbn-root></cbn-root> is displayed in the body section. Yet, utilizing Chro ...

Selenium in combination with PhatntomJS is experiencing difficulty initiating a session

I have been using PhantomJs in conjunction with Selenium for headless automation and it was functioning perfectly until today. However, I encountered the following exception when trying to initialize the PhantomJs driver: The code snippet that led to the ...

Efficiently handling the conversion from backslashes (\) to single

We are facing a challenge in producing a unique string format: "/Date()/". It is important to note that backslashes do not function as escape characters in this case; rather, they represent the literal string. Our .NET team member suggested using syntax ...

Instructions for duplicating the current website address into another browser window or document without user input

I have a desire to create a button within a web browser that, when clicked, will either copy the current URL address into a file or open another web browser and paste it there. Being new to programming, I am unsure of which language to use for this task. ...

Unsuccessful Invocation of Servlet by Ajax Function

I have a situation where I am trying to trigger an Ajax javascript function from my jsp file, with the intention of loading a servlet for further processing. The issue I am facing is that even though I am able to pass values from the jsp to the ajax functi ...

Is it possible for PHP to send an HTTP Get request to Java?

I am currently exploring ways to establish communication between PHP and Java. My goal is to have PHP pass an ID parameter to a Java file, where Java will process the ID and return an array back to PHP. I have researched various methods such as PHP/Java ...

The ChromeDriver is experiencing difficulties in correctly switching between frames

Having trouble switching frames properly. The project is a maven project with the following pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.o ...

Switching my Selenium code to HtmlUnit: A Step-by-Step Guide

Currently, my Selenium code is working perfectly fine. However, I am looking to convert this code into HtmlUnit. I know I can use the HtmlUnitDriver like WebDriver driver = new HtmlUnitDriver(); I want to make it purely HtmlUnit. Below is the code that I ...

Using Java to extract data from a JSON file containing dynamic fields

Looking to extract data from a JSON file that contains objects with dynamic fields. Take, for example, the "items" section which includes objects with unique identifiers like “1c68b853-2a07-4409-ad61-8650212f3260” along with additional attributes. Ther ...

What is the process for setting Glassfish 5 to utilize Moxy as the primary Provider?

As we transition our web application from Glassfish 3 to Glassfish 5, an error appeared during the migration process for a particular request. [2019-09-17T15:57:30.732-0600] [glassfish 5.0] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=241 _ThreadNa ...

Locating and identifying visible elements on a web application with Selenium

I am struggling to locate visible elements on a web application page using Selenium. Specifically, I need to identify a clickable row and then click on it. The challenge lies in the fact that these elements are dynamically generated and do not appear in ...

Dealing with a distinct dynamic identifier in a JSON structure - what's the best approach?

Exploring json handling for the first time using retrofit to interact with an API. The unique ID "f9dcf2ef-8647-46c1-b1cc-7e2bb6c3caa2" varies whenever the username in the URL {username} is changed. { "status": 200, "foundmatch": true, "requested": ...

Most effective way to transfer a variable along with its corresponding value from one class to another class

As an Automation Quality Assurance engineer, I utilize Eclipse, Java, and Selenium for the majority of my automation tasks. Currently, I am creating scripts that involve generating a unique number as one type of user (user 1) and then searching for that sp ...

Guide on sending the boolean result returned from controller to view in Spring MVC

I need to pass the boolean value returned by my controller method to the view, where I can display an alert message based on this flag. Here is my controller code: @RequestMapping(value = "/testing", method = RequestMethod.POST) public Boolean testing(@Re ...

Converting JSON data in Spring MVC 3.2 for REST services

I am encountering an issue while attempting to send a List of data as JSON from my Spring Controller. The error message "Could not find acceptable representation" is being thrown. Below are the snippets of code from different parts of my application: pom. ...

Unable to convert JSON data into a datatable

My code looks like this: $.ajax({ type : 'POST', url : 'classfication_of_productjson.html', dataType : 'json', data : { "search_bunrui_code ...

Analyzing URL parameters in Java

It is important to note that the following two URLs should be considered equivalent: http://localhost?asdf=1&qwer=2 http://localhost?qwer=2&asdf=1 However, when using the 'equals()' method from the URL class, they are identified as different. How ...

Create a JSON by merging two maps of strings

After examining the JSON String that I was expecting, here is what it looks like: { "startDate": "2013-01-01", "columns": "mode , event", "endDate": "2013-02-01", "selection": { "selectionMatch": "123456789012", "selectionT ...

Having trouble resolving the issue of connection timeout with Chrome while utilizing chrome version 78 alongside chrome driver version 78.0.3904.70? Here's a step-by-step guide on how to troubleshoot and fix this error

After updating my Chrome browser to version 78, I encountered an error when trying to run any automation code. To resolve the issue of timeout while connecting to ChromeDriver and related test frameworks, ensure that ports are protected from access by mal ...

Is there a method to activate a button labeled with the attribute ignorecase by clicking on it

I need to programmatically click on a button with the text "Settings", ignoring the letter case. Here is my code snippet: WebDriverWait wait = new WebDriverWait(driver, THIRTY_SECONDS); return wait.until(ExpectedConditions.presenceOfElementLocat ...

No IOException was found in the variable e

Related Question: Exception is NULL always I'm facing an unusual issue involving an IOException object that I haven't been able to resolve. The code in question is as follows: try { // This section may not be critical, but it could be related to the ...

Step-by-step guide on making a GET request with Java Spark

For my Java Spark project, I need to access a third-party API The API endpoint for a GET request is: I am seeking guidance on how to connect to this API using Java Spark and handle the response Upon attempting to access the API, the response returned wa ...

Converting JSON Data to Java Object

I need some help with a specific issue I'm encountering. I have retrieved a JSON string from MongoDB and I am trying to extract all the values of 'photo' and store them in an ArrayList. Despite finding examples online, I haven't been successful in making ...

Managing the visibility of foreign or packaged object attributes with JsonView

Within my data object, there is a combination of primitives and data objects from external libraries that I am utilizing in my project. Although I can use the @JsonView annotation to control which data is returned to the browser during Ajax calls, this app ...

WebDriverException: Unable to establish the new session. Configuration not found for {platform=WINDOWS, browserName=FIREFOX, version=3.6}

Recently, I have started learning about Selenium Web driver and Grid 2. While attempting to execute a test case, I encountered an exception: Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find ...

Ways to verify if certain text information is present on the webpage

Is there a specific way to determine if certain texts are present on a webpage? It would be ideal to check multiple texts at once. For instance, checking for "client", "customer", and "order" in the page content. Below is an example of the HTML code snip ...

obtain information from a Java servlet on a web page

I am working on a webpage that displays various coordinates (longitude, latitude), and I need to create a Java class to sort these coordinates. My plan is to send the coordinates to a Java servlet before displaying them on the webpage. The servlet will th ...

Unable to convert JSON data to char array due to a NumberFormatException while using editText

I am attempting to parse JSON on Android, and after parsing the JSON, I want to convert the inputted ID in Edittext to a char array. However, I am encountering a NumberFormatException. I don't think this is a silly question, but where could the prob ...

De-serializing Plain Old Java Objects (POJOs) with Lombok to send intricate JSON payloads using

It's my first time trying out POJO and Lombok in combination with Rest Assured for handling complex JSON data. I opted for this approach due to the extensive number of fields present in the JSON structure. Here is an illustration of the JSON format: ...

Transferring data using Jackson-2.9.7: JSON import/export operations

Greetings, Currently, I am engaged in a project that involves allowing the user to import/export program data into a JSON file. The data is of type TreeMap<String, List<Observation>>, where Observation is a class containing LocalDate date and ...

Clustering JSON documents with the power of Machine Learning

Looking to conduct document clustering using JSON String data containing various key-value pairs of String and Number types. The goal is to cluster documents based on similar types of keys and values. For example, consider the following JSON Document: {" ...

Selenium tool for delaying the execution until an Element appears

Just started using the selenium framework and created a method to check for the presence of an element. Here is the method I came up with: public class WebUtlities { WebDriver driver; public void waitforElement(WebElement element) { W ...

Automating SAP Fiori with Selenium (JAVA): A Step-by-Step Guide

Looking to automate SAP Fiori (Browser) using Selenium in Java. Are there any external tools that need to be installed or specific SAP configurations that need to be enabled in order to successfully read elements within the Fiori interface? Attempts have ...

Encountering ElementNotInteractableException while using Selenium in Java to send Arrow Up to a number input

When trying to input a salary into a tax calculator website, I encountered an issue where an arrow_up or arrow_down key needed to be pressed in order for the tax amounts to be calculated instead of using the enter key. Despite researching online and findin ...

The deserialization of 0 and 1 to "Boolean?" failed in Moshi

When attempting to deserialize a JSON field with values of 0, 1, or null into a "Boolean?" data type, the following custom Annotation is used: @Retention(AnnotationRetention.RUNTIME) @JsonQualifier annotation class BooleanType class BooleanAdapter { @ ...

Hide the value of a specific key in a JSON object

Looking for assistance with masking specific fields in JSON request and response logs. I want to be able to print the JSONs in the log while avoiding displaying certain secured fields. Here is an example: Original JSON: {"username":"user1","password":"12 ...

What is the best way to choose a specific passage from a lengthy piece of text?

Upon completing the registration process on the website, I am sent my login credentials via email in the following format: some text / login: [email protected] / password: example123 / some text I am struggling to extract and copy just the l ...

AngularJS Relationships with Hibernate

Working with two classes that have a one-to-one relation, I have successfully retrieved their data and displayed it in HTML using REST service and AngularJS. However, when attempting to display the airport ID on the asset page using {{asset.airport.id}}, n ...

Dealing with Exception in thread "main" for org.openqa.selenium.NoAlertPresentException: handling absence of alert in Selenium with Java

I am looking for a way to manage this exception in Java and Selenium. In my current code, I have implemented the following: Alert alert = driver.switchTo().alert(); alert.accept(); driver.findElement(By.xpath("//*[@id="btnGoCon ...

How to initialize an enum in Java using Gson

Take a look at this piece of code: public class MyClass { public static enum MyEnum { ENUM_A("This is option A"), ENUM_B("This is option B"); private String description; private MyEnum(String desc) { this.description = desc; } ...

What could be the reason behind Cesium viewer's failure to show a model after I upload it?

My application features a 3D map of a city with an "Add building" button. Upon clicking this button, a model of a building should be inserted into the map. However, all I see is a selection marker at the intended location without the actual building appea ...

The WebDriver Manager for Selenium Automation is experiencing issues with the latest Chrome update, version 116

I implemented the selenium framework and included this dependency. However, I encountered an issue where the browser wasn't being invoked due to Chrome version 116. <dependency> <groupId>io.github.bonigarcia</groupId> <art ...

Converting Java Interface to JSON using Gson: A Step-by-Step Guide

My current situation involves the following structures: public class Zoo{ int id; String name; List<Animal> animalList; List<Bathroom> bathrooms; } public interface Animal{ //animal has some common methods, but is mostly for naming ...

Issue with data interpretation between jQuery and Java

My character encoding is currently set to ISO-8859-1. I'm utilizing an AJAX call with jQuery.ajax to communicate with a servlet. After serialization by jQuery, the URL appears as follows: https://myurl.com/countryAndProvinceCodeServlet?action=getPro ...

What purposes does the pom.xml file serve in Maven other than managing dependencies for Selenium?

I'm looking for some clarification on the interview question related to the pom.xml file: Aside from managing dependencies in Selenium, what other purposes does the pom.xml file serve? ...

How to make an AJAX call to httprequest using playframework 1.5.0

When attempting to make an httprequest within an ajax call, I keep encountering an internal error. However, I have confirmed that the http request call is correct outside of the ajax call. What could be causing this issue? Below is the code snippet: http ...

Managing Custom Boolean strings using Jackson Streaming API

Utilizing the Streaming API provided by Jackson for parsing JSON strings, I have a requirement to recognize "YES" as a boolean type. JsonFactory f = new JsonFactory(); Following that, I proceed with: JsonParser jp = f.createJsonParser(jsonString); Then ...

Encountering an exception while parsing JSON

I'm trying to extract specific fields from a JSON object. Here is an example of the JSON data- { "id": "100000224942080000", "name": "Tech Geeky", "first_name": "Tech", "last_name": "Geeky", "link": "https://www.facebook.com/tech.geeky", ...

Selenium - Warning: Unable to interact with element

Requirement: I need to update fields on a URL and click a button using Selenium. (See screenshot of webpage & HTML details below) Problem: An error is being returned as displayed below Error Message: Exception in thread "main" org.openqa.selenium.Elemen ...

Validating Active element through Java with WebDriver

When logging in to Yahoo mail, the cursor automatically focuses on the Yahoo ID text field. I need to confirm whether the cursor is indeed focused on the Yahoo ID field. Here is the HTML code for the text field: <input name="login" id="username" maxlen ...

I must interact with the video within the iframe by clicking on it

I am trying to interact with an iframe video on a webpage. Here is the code snippet for the video: <div class="videoWrapper" style="" xpath="1"> <iframe width="854" height="480" src="xxxxxxx" frameborder="0" allow="autoplay; encrypted-media" all ...

Having trouble obtaining the handle of a recently opened window in Internet Explorer with Java?

Upon clicking a button labeled "Go" in my code, a new window is opened. Strangely, when checking the task manager, I notice that there are two instances of IE running. However, despite this, the method getWindowHandles() fails to retrieve the handle of the ...

Modify the text of a button when hovered over (JavaFX)

Can anyone help me figure out how to change the text of a button when it is hovered over? Approach: if (button.isHover()){ button.setText("new message"); } I'm open to either a css fix or a code solution! ...

Producing two observables, handling the output, and subsequently emitting a different one

I have been assigned a task that involves working with multiple observables in a specific way: The goal is to emit two observables (obs1 & obs2), process their results, and then call another observable (obs3). It's important that while processing the resu ...

What is the way to determine the length of a list in a velocity template?

Is there a way to determine the size of a list in a velocity template? I am currently working with version 1.4 of Velocity. List<String> list = new ArrayList<String>(); ...

Image capture by automation

I'm in the midst of a project automating tasks, where I have designed a basic program to generate testing reports and capture screenshots. package ReportTest; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; im ...

Discovering strings within strings on the Android platform

In my current project, I am dealing with a lengthy JSON text that contains movie titles. I need to extract these titles from the following pattern: ((((((( .","title":" AND ","type":" ))))))) After researching other solutions, I came across one appro ...

Waiting for AJAX request to complete in Selenium following a button click

After completing a form and clicking the submit button, I aim to delay checking for the newly inserted data in my view until the call is made. I'm exploring ways to make this work. Upon inspecting the page markup, it seems that the view refreshes automati ...

JSON - just return an Integer instead of a Long

Is there a way to retrieve an Integer instead of a Long from JSON data? When working with JSON in Java, I encounter an issue where the parser returns numbers as type Long, but I need them to be Integer. I attempted casting the long value to an integer, h ...

Capturing the action phase in Liferay to change the cursor to 'waiting' mode

I'm currently working on a large Liferay project and have encountered a specific issue: Whenever something in the system is loading or processing, I need to change the cursor to a waiting GIF. While this is simple when using Ajax, there are many instances ...

Access and retrieve xlsx file from a Java-based Restful backend

When I upload an excel file from my UI using an ajax-post call and try to read it from my backend Restful service Java code, I am encountering issues in printing the excel file contents correctly. Although the file name and other attributes are printing co ...

Determine if an element in Selenium Java is stale using the debugger

Is there a method in Eclipse debugger to determine if a Selenium element is stale? org.openqa.selenium.StaleElementReferenceException: The element has become stale and is no longer attached to the page document. ...

Utilizing WireMock to simulate HTTP server responses. Error finding file with WireMock

Recently began using wiremock and encountered a situation where I need to mock a GET request with a specific json response. When including the json in the expected response like this; .withBodyFile("product.json")) I'm getting an error saying java. ...