cancel
Showing results for 
Search instead for 
Did you mean: 

[TechCorner Challenge #7] Retrieve Data from a Web Page

SOLVED
Highlighted
Community Manager

[TechCorner Challenge #7] Retrieve Data from a Web Page

Hi Community members!

 

I’ve got a new task for you today. It will help you practice your TestComplete skills and, also, get into the Leaderboard!

 

Many of you know @TanyaGorbunova - she is a SmartBear Community Manager and contributes a lot to the Community. Do you how many of her answers were marked as Solutions? This kind of info can be retrieved using TestComplete!

 

Task: Record a TestComplete script that will go to a user profile page (@TanyaGorbunova in our case) and get the number of Solutions for a specific community member.

Difficulty:Star_Gold.pngStar_gray.pngStar_gray.png

 

Share your code (a keyword test or script) and the number of Solutions Tanya has in the comments below.

 

Note: You will need the Web Module to fulfill this task.

 

Good luck!


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Tags (1)
2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Occasional Contributor

Retrieve Data from a Web Page

Task: Record a TestComplete script that will go to a user profile page (@TanyaGorbunova in our case) and get the number of Solutions for a specific community member.

 

This is a solution created for [TechCorner Challenge #7]

 

 

function GetSolNumber()
{

//Open the user profile page
Browsers.Item(btChrome).Navigate("https://community.smartbear.com/t5/user/viewprofilepage/user-id/1737");

// Get the number of the solutions
var ProfilePage = Sys.Browser().Page("*");

//Get the name of the profile

var name = ProfilePage.QuerySelector('span.login-bold').contentText;

// Identify the Solutionsdiv
var solutionSec = ProfilePage.QuerySelector('div.UserSingleStatistic.lia-statistic-net_accepted_solutions.lia-component-users-widget-single-statistic div.lia-statistic-value');

// Check the result
if (solutionSec != null)
// If the element was found, display the number of Solutions for the selected community member.
{
Log.Message("the number of Solutions for the profile of the member " + name + " is: " + solutionSec.contentText);
}
else
// If the element was not found, post a warning to the log
Log.Warning("The element was not found.");

}

View solution in original post

Tags (1)
Highlighted
Occasional Contributor

Re: [TechCorner Challenge #7] Retrieve Data from a Web Page

Task: Record a TestComplete script that will go to a user profile page (@TanyaGorbunova in our case) and get the number of Solutions for a specific community member.

 

This is a solution created for [TechCorner Challenge #7]

 

Hi All, 

 

Was unsure of how to post a keyword test, so here is a screengrab of it from TestComplete

My test uses Keyword with some scripted routine

cbroad_0-1598275480243.png

 

Where the script is removing the "solutions" text from the ContentText of the mapped area,

 

function StringReplace(text)
{
var str = aqString.Replace(text, "Solutions", "");
return str
}

 

Resulting in:

cbroad_1-1598275526461.png

 

View solution in original post

Tags (1)
5 REPLIES 5
Highlighted
Occasional Contributor

Retrieve Data from a Web Page

Task: Record a TestComplete script that will go to a user profile page (@TanyaGorbunova in our case) and get the number of Solutions for a specific community member.

 

This is a solution created for [TechCorner Challenge #7]

 

 

function GetSolNumber()
{

//Open the user profile page
Browsers.Item(btChrome).Navigate("https://community.smartbear.com/t5/user/viewprofilepage/user-id/1737");

// Get the number of the solutions
var ProfilePage = Sys.Browser().Page("*");

//Get the name of the profile

var name = ProfilePage.QuerySelector('span.login-bold').contentText;

// Identify the Solutionsdiv
var solutionSec = ProfilePage.QuerySelector('div.UserSingleStatistic.lia-statistic-net_accepted_solutions.lia-component-users-widget-single-statistic div.lia-statistic-value');

// Check the result
if (solutionSec != null)
// If the element was found, display the number of Solutions for the selected community member.
{
Log.Message("the number of Solutions for the profile of the member " + name + " is: " + solutionSec.contentText);
}
else
// If the element was not found, post a warning to the log
Log.Warning("The element was not found.");

}

View solution in original post

Tags (1)
Highlighted
Community Manager

Re: [TechCorner Challenge #7] Retrieve Data from a Web Page

Conrgats @SiwarSayahi ! This works great🙂

 

By the way, the "Use XPath and CSS selectors for web objects" mode in TestComplete makes it much easier to work with CSS and XPath selectors. It allows you to copy selectors from Object Spy and create a script manually, or record a test as usual - TestComplete will automatically use selectors when mapping objects.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Manager

Re: Retrieve Data from a Web Page

Yaaaah. Great code, @SiwarSayahi!

 

I've posted 823 solutions so far and it's not a limit!

Participate in the new weekly challenge and share your skills in web testing.

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Occasional Contributor

Re: [TechCorner Challenge #7] Retrieve Data from a Web Page

Task: Record a TestComplete script that will go to a user profile page (@TanyaGorbunova in our case) and get the number of Solutions for a specific community member.

 

This is a solution created for [TechCorner Challenge #7]

 

Hi All, 

 

Was unsure of how to post a keyword test, so here is a screengrab of it from TestComplete

My test uses Keyword with some scripted routine

cbroad_0-1598275480243.png

 

Where the script is removing the "solutions" text from the ContentText of the mapped area,

 

function StringReplace(text)
{
var str = aqString.Replace(text, "Solutions", "");
return str
}

 

Resulting in:

cbroad_1-1598275526461.png

 

View solution in original post

Tags (1)
Highlighted
Community Manager

Re: [TechCorner Challenge #7] Retrieve Data from a Web Page

@cbroad Awesome job! Thank you for posting this!🙂

 

Next time, feel free to attach your whole project🙂


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors