Questions tagged [groovy]

Groovy, a versatile programming language designed for the Java platform, stands out as an exceptional choice. This dynamic language possesses remarkable qualities resembling Python, Ruby, Perl, and Smalltalk. Notably, it effortlessly serves as both an excellent scripting language and an object-oriented powerhouse on the Java platform.

Tips for retrieving the specific JSON node instance with Groovy?

When working with JSON files in Groovy, it can sometimes be tricky to differentiate between different types of nodes. For example, the "value" and "onclick" nodes in the provided JSON file both return as ArrayLists, even though logically we expect "value" ...

Use geb to upload the file

Hello, I am trying to upload a file during my test using Geb. The instructions in the Geb-book (http://www.gebish.org/manual/0.9.0-RC-1/navigator.html#file_upload) are not working for me. My HTML code includes a file input field: <input id="bla-bl-bla ...

Retrieving the XML data instead of JSON from a RESTful API

I have been practicing with the REST API to enhance my skills in Groovy-REST. Currently, I am able to extract specific JSON data from the REST response using SOAP UI 5.0 and generate a simple output from it. Interestingly, SOAP UI also provides an XML ver ...

Discover the effective approach for executing JMeter to effortlessly display the absent elements

I have two separate GET APIs that return response codes containing an ID number and a corresponding title. For API_1, here are some sample responses (with 100 IDs): { "result": "OK", "obj": { "list" : [ { "id" : 9 ...

Linking a JSON or JSON array to a Grails object

When I receive a response in the form of a JSON array, it can either be an array of values like ['1', '1', '2'] or an array of objects like [{'name': 'blabla', age: '30'}, {'name': ...

Updating a specific ID using jQuery in a Grails application - How can this be achieved?

I am working with a view file that looks like this: <html> <head> <meta name="layout" content="main" /> <title><g:message code="User's profile" /></title> <g:javascript library="jquery"/> ...

Creating a JSON builder using arrayJson in Groovy is an effective way to easily

I'm a beginner in Groovy and I'm trying to create a JSON object using the builder { "query": { "bool": { "must": [ { "bool": { "should": [ ...

Tips for combing 2 JSON Arrays using Groovy

Looking to combine two JSON arrays into one using Groovy scripting. def branchTags = new JsonBuilder() branchTags branches, { String branch -> tag branch type 'b' } println(branchTags.toString()) //produces [{"tag":"Bra ...

Exploring the Potential of Nested Iterable Associations with Groovy's JsonBuilder

I've been encountering 2 issues with the JsonBuilder that I can't seem to resolve despite my best efforts in researching. Although I'm close, the solution isn't quite right. The arrays for days and agendas are not displaying as expected; they are showing ...

Incorporating groovy script into HTML: Is it possible, akin to embedding JavaScript

Can groovy script be embedded in HTML similar to JavaScript? I am interested in creating an onclick button event that utilizes groovy script instead of JavaScript. Thank you. ...

Save a JSON-formatted string as a JSON file

I have a string in JSON format that looks like this: arbre={"name":"flare","children":[{"name":"Algèbre","children":[{"name":"Nombres Fractionnels","children":[{"name":"Addition fractionnelle","size":8.333333333333334}, {"name":"Division fractio ...

Tips for maintaining an open browser using Selenium WebDriver 4 and Groovy in JMeter

I'm currently using a JMeter script to open functional Firefox browsers, but I've encountered an issue where the browsers close once the script finishes running. Here is the code I am using: WDS.sampleResult.sampleStart()     def display = WDS.vars.ge ...

Retrieving object names from an array using Groovy and JSON

I received a JSON response from an API call and I'm trying to determine the number of success objects and error objects within the results array in my given example. Although I've used the jackson object mapper to retrieve the value assigned to an object, ...

Using either Java or Groovy, iterate through a hashmap and showcase an HTML table within a Velocity template

Just a heads up: Some users may have trouble reading code comments. For the record, this is not related to any homework assignment. I'm attempting to combine HTML and a hashmap for the first time. Despite searching for explanations online, nothing see ...

Convert XML to JSON effortlessly even without knowledge of individual keys using Groovy

I received an XML web service response and I am interested in converting it to JSON, even though I do not have knowledge of all the keys. This is just a glimpse of the structure, the actual response is much larger. Can this conversion be achieved using G ...

Exploring the depths of JSON nested maps in Groovy: a step-by-step guide

I have received the following JSON output from AWS DynamoDB and I am looking to loop through it in order to populate a table within Jenkins Parameters using a Groovy script. Is this achievable? JSON: [ { "test": { "S ...

Error with JSON parsing caused by commas in JSON file using JsonSlurper

When JSON data is received in my controller as params.formData, it has the following structure: '{"year":"2014","resource":["Smith, John","Foo, Bar"]}' Here's the code snippet I use to parse this data: .... def slurper = new JsonSlurper() def data = slu ...

Jenkins Node Version Switch: No executables were located in the directory "/usr/local/n/versions/node/11.15.0/bin"

Every time I run my Jenkins pipeline, I keep encountering the following error: Couldn’t find any executable in "/usr/local/n/versions/node/11.15.0/bin" The Jenkins Slave is set up on an AWS Linux machine with both node 16.x and node 11.15.0 in ...

Remove quotation marks from numbers in JSON Builder

I am facing an issue while running the groovy scripts below to create a JSON template. The problem lies in the fact that the integer values in the template are displayed within quotes, treating them as strings. cat port.txt 1001 Below is the JSON builder ...

Tips for eliminating a web element from the field using Groovy

As outlined in chapter 4.10 of this guide: To eliminate the contents of a webElement, I can execute the following: webElement << Keys.chord(Keys.CONTROL, "a", Keys.BACK_SPACE) However, I find this approach to be less than ideal. Is there a way to ...

Creating a GlobalVariable dynamically in Katalon during runtime using script mode

I am a beginner with the Katalon Studio tool and trying to dynamically add GlobalVariables by inputting both the variable name and value. I have found a piece of code that should help me achieve this, but I am struggling to understand it as it utilizes met ...

Encountering an error in JMeter with Selenium/WebDriver: class org.openqa.selenium.support.ui cannot be resolved

Operating System: Ubuntu 20.04.6 Java Version: openjdk 17.0.8.1 2023-08-24 JMeter Version: v 5.6.2 Selenium/WebDriver Support Version: 4.13.0.0 Groovy Script: import org.openqa.selenium.support.ui as ui; WDS.sampleResult.sampleStart() WDS.browser ...