18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
[SOLVED]Can't check element existence
Hello,
I've tried to figure this out, and I searched through the forum but haven't found anything to help me. I'm trying to check if the link is on the page before clicking on it.
What I have tried doing so far:
if (_condition(_byId("ctl00_HyperLink15")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: [Exception] [object Error]
if (_condition(_link("Dashboard")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: [Exception] [object Error]
if (_containsHTML(_byId("ctl00_HyperLink15")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
if (_containsHTML(_link("Dashboard")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
if (_assertNotNull(_link("Dashboard")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
if (_assertNotNull(_byId("ctl00_HyperLink15")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
What do I do? I'm using the latest version of Sahi. Everything else works fine. Plus I've found that when I use the playback, it goes through the code ignoring the if condition, carries on and types SUCCESS in the end. May be this will fix once I fix my if condition.
Thank you.
I've tried to figure this out, and I searched through the forum but haven't found anything to help me. I'm trying to check if the link is on the page before clicking on it.
What I have tried doing so far:
if (_condition(_byId("ctl00_HyperLink15")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: [Exception] [object Error]
if (_condition(_link("Dashboard")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: [Exception] [object Error]
if (_containsHTML(_byId("ctl00_HyperLink15")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
if (_containsHTML(_link("Dashboard")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
if (_assertNotNull(_link("Dashboard")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
if (_assertNotNull(_byId("ctl00_HyperLink15")) == true) {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
I get: undefined
What do I do? I'm using the latest version of Sahi. Everything else works fine. Plus I've found that when I use the playback, it goes through the code ignoring the if condition, carries on and types SUCCESS in the end. May be this will fix once I fix my if condition.
Thank you.
This discussion has been closed.
Comments
if (_containsHTML(_byId("ctl00_DashTextLink"), "Dashboard") == true) {
_click(_link("Documents"));
_click(_link("Dashboard"));
}
Don't know why it's skipping the Documents part. It's not clicking on those things in order, it's always executes the last line in the condition method. Goes to Dashboard without going to Documents first. And it doesn't matter what I put in there, it always goes to the last line.
function testDashboard() {
_click(_link("Dashboard"));
_click(_link("Dashboard No1"));
}
if (_containsHTML(_link("Dashboard")) != null) {
testDashboard();
}