Question regarding Basic command for a beginner


I made a script to put a few charging station on deactivate and it works well.
but there is only one issue/bug in my script,

as you can see on the photo some of thous charging stations that I want to deactivate have 1 socket,
which I got a problem with that so my script search for second socket to also deactivate but actually there is no second socket at all,
how can add some extera script to: if secound link=Deactivate not exist, go to the next one?!


You can do this simply through how you are locating your elements. The idea is:

1.) Find the HTML element that uniquely identifies (contains) an individual charging point, along with all sockets associated with that charging point.
2.) Within that context, find all “Deactivate” links, and click them.

If you can share the HTML for one of the charging stations, and all associated sockets, I can give you a locator.

1 Like

Batch DeActiveren Script

This scrip goes through all of the stations that you I am already uploaded,

And store the Status of the charge station which could be Disable (Not monitored), OK (Idle/charging status), Error (Error/Timeout of charging station),

And after scan the status of the charge station those are on the Error status set it on Deactivated + leave a note on the Monitoring Logs Like: “NotMonitored | Amir: Address data not yet processed (New Station)” OR “NotMonitored | Amir: Yet to be installed (New Station)”

We could use this script to Deactivate the new station which is not installed yet to not showing as an error on our overview page.

For Example this a Charge station name : EVB-P1541091 which have even more sockets,

In this case 6 sockets : EVB-P1541091_1/EVB-P1541091_2/EVB-P1541091_3/EVB-P1541091_4/EVB-P1541091_5/EVB-P1541091_6,

So what I want is that the script search for all of the existing sockets which each of them has they own Deactivate Link and click on that, so it doesn’t matter if the charge station has 1 or more charging point,

The script should detect all of them and do the job.

I have attached the Batch DeActiveren Script for 1 & 2 socket which now I want to make it a little bit smarter and the script by them self-recognize all of the existing Deactivate Link and put the not on it and Deceived te charge points.

I have also attached the HTML for one of the charging stations + photo Charging Station which have 6 charging points,

Thanks you for your attention.Batch DeActiveren 2socket.html (15.4 KB)
Batch DeActiveren.html (12.1 KB)

HTML for one of the charging stations.txt (100.0 KB)

If I’m understanding you correctly, this should be super simple. You basically want to click EVERY deactivate link that is available on the page at any given time. If so, it’s really really easy:

1.) This xpath should identify all Deactivate links on the page:


2.) You can do this using the Object Repository in combination with WebUI calls, but I’m just going to show you how to do it with selenium, as it’s much easier (in my opinion):

import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.openqa.selenium.By

WebDriver driver = DriverFactory.getWebDriver();
By locator = By.xpath("//a[text()='Deactivate']");
List<WebElement> deactivationLinks = driver.findElements(locator);
while(deactivationLinks.size() > 0) {
    // if clicking a link causes the page to reload and/or redirect, you will need a wait condition here
    deactivationLinks = driver.findElements(locator);

The logic is roughly:

  • Generate a list of all existing Deactivate links on the page
  • As long as the list contains at least one link, click it
1 Like

I have try it on Selenium IDE (chrome extension) but it did not succeed & I dont not How should I use that and where !
Can you tell me how can I put this code in my script ?

you can find my Test suites in the attachment.Batch Deactivate side (1.9 KB)

Sorry, this is a forum for Katalon Studio. Not sure how Selenium IDE came into the conversation.

Just put the code I shared directly into your test script. If it doesn’t work as written, we’ll need to see what errors you’re getting.

is there any way that i can use this code in Katalon recorder ? or it just work in Katalon Studio !
Becuse I try to use Select by value command for selection a value in dropdown but in katalon record there is no such a command!

I’ve never used the recorder, so I’m not sure. But my guess is that you could not copy/paste the code I linked above into the recorder in any way.

1 Like