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.
How to capture webpage title in the script
Hi There,
I want to capture the title of webpage in my script, but i am not able to do so..Can you please suggest me something?
Regards,
Tina
I want to capture the title of webpage in my script, but i am not able to do so..Can you please suggest me something?
Regards,
Tina
This discussion has been closed.
Comments
To get the title of the webpage use:
var $Title = window.document.title;
_alert($Title);
Regards
Sumitra
Try _title() API to get title of the webpage.
_alert(_title());
would display a Popup window with the title of the webpage.
Regards
Theeran.
Can you please tell me how to check meta tags of a page?
if i want to check this :-
<meta name="description" content=" Rich Foods List, Nutrition Facts and Rankings. Compare options and find healthier eats. Practical Nutrition Information and personalized analysis totally free." />
then what i have to write ?
Thanks in advance.
Regards,
Tina
Try with the following Script,
Assertion can be done with any of the meta Tag attributes and you can check your meta Tag.
Regards
Theeran.
Its not working
Can you please suggest something else?
Thanks & Regards,
Tina
If your source page contains more than one meta tags then you will have to know the meta tag on which you want to do assertion.
In your case, it should be:
Let me know if this solves your issue.
Regards
Sumitra
Thanks, your code is working. But I don't know why I am facing problem in matching two strings.
i am doing it like this :-
function metacheck($pageTitle,$meta_description)
{
var pTitle = _title();
var $b=document.getElementsByTagName("meta")[3].content;
if(pTitle == $pageTitle){
_log('Correct page title', 'success');
}
else{
_log('Incorrect page title', 'failure');
}
if($b == $meta_description){
_log('Correct meta description', 'success');
}
else{
_log('Incorrect meta description', 'failure');
}
_alert($b);
_alert($meta_description);
}
and passing this function :-
//seo check
var $seo_title = "Rich Foods - Ranked List";
var $seo_description =" Rich Foods List, Nutrition Facts and Rankings. Compare options and find healthier eats. Practical Nutrition Information and personalized analysis totally free.";
_include("nr_common.sah");
metacheck($seo_title,$seo_description);
Can you please tell me, where i am doing mistake?
Thanks,
Tina
Try with this code:
Check if this solves your issue.
Regards
Sumitra