I want to make it dynamic. Like, instead of creating 3 different test cases for the search purpose. I want to create only 1 test case which can handle all the 3 searches through the if/else condition. But for that, I have to pass the Search Test Object either through a Data file or a Global variable. Is that even possible?
Could you write a test case which makes a query to your Application Under Test with all 3 options given with a sample concrete values. For example,
Search By name <= âfooâ
Global search <= âbarâ
Advanced Search <= âbazâ
You should make the sample code runnable; it should PASS without compile errors.
Once written, please share the entire code of your test case script here.
Provided with a concrete code, then we would be able to understand what you want to do. Provided with your base code, possibly somebody would be able to advise you how to revise it so that it accepts external data to make it âdynamicâ.
I apologize if I wasnât clear enough!
Letâs say we have 3 search options on the same page. I want to search âABCâ on the given list of Projects. And it can be searched through all the given search options.
And I want to use a search button through a data file like CSV. it should depend on the user through which search he wants to filter out the results.
So, I was asking is that possible to pass the WebElement[ i.e Search button] through the data file, and if yes how?
Like if the user wants to filter through Global search, he just needs to pass the Global Search Xpath in the file.
What @kazurayam is struggling with is your English. Kaz is not a native English speaker, but I am. I canât understand what it is you want to achieve since most of your questions make no sense to me. Sorry.
What Kaz is asking you to do is write some code. Get the idea started in code. Code (backed up with good comments) has a way of removing ambiguities and providing clear statements of your intentions. Your (and our) English, on the other hand, can be full of subtle twists in meaning which seriously impedes true understanding.
First step: Write a Test Case that searches using just option 1.
Second step: Add the ability to repeat the search using option 2.
â Reload the page, then choose option 2.
Third step: Add a search for option 3.
â Again, reload the page, then choose option 3.
If you get stuck, post a specific question about a specific problem. And make sure we can see your code.
It is not possible to pass the WebElement or TestObject through the data file (at least I donât know how). You can only pass Strings and Numbers. However, you can pass the String that makes up the xpath, or css, or the pathway or your Object Repository that composes the WebElement or TestObject. You will have to recreate your âSearchâ WebElement, or TestObject, from your String, like:
//Calling the LOGIN Test Case
WebUI.callTestCase(findTestCase("Test Cases/Login_Logout_Scenario/Login_Logout_Scenario"),
[("User_Email"): user_input , ("User_Password"): user_password ], FailureHandling.STOP_ON_FAILURE)
//Click on project main page
if(WebUI.waitForElementPresent(Project_Link, 60))
{
WebUI.click(Project_Link)
println('Project detail mode is displayed')
}
else
{
println("Couldn't find the Project Button")
}
WebUI.delay(5)
//Get the total count of projects before searching
GIVENCount = WebUI.getText(TotalCountOfProject)
TotalProjectCount = GIVENCount.substring(8,12)
System.out.println("There are " + TotalProjectCount + " Project records.")
//Click on the Search button. Search project through project name.
WebUI.waitForElementClickable(ProjectSearchByName, 30)
//Set Project Name fetching from the file data
WebUI.setText(ProjectSearchByName, ProjectName)
System.out.println("The entered Project name is : " + ProjectName)
WebUI.delay(5)
// Declaring the variables
String GetProjectName, ProjectNotFoundMessag, Headingtext, CellText
//Calling the verification method here!!!!
CustomKeywords.'project_Page.Project_Search.ProjectSearchCase'(ProjectName, EditProjectName,
ProjectNotFoundMessage, ProjectNotFoundMessag, Headingtext, CellText)
Why not you expose the URL of your target web page?
Is it a private one or you canât share it to us for some security reasons?
If so, I am discouraged. If you can not tell us the target URL, I would quit. Because it is very difficult to think about the HTML that I can not actually see.
Your question is highly dependent on the structure of the HTML source. Therefore we need to be able to open it in browser in hand to see the HTML source code and study in detail.
HTML source code matters! Please understand this.
But you can not share the live URL and username/password for security reason. OK, I understand it.
Then, please save the target page (after login) into a MIME HTML file, and share the file here.
The following post tells you how to save a web page into a MIME HTML file.
The credentials (username/password) will not be included in the MHT file. So you need not be worrried about the security.
Provided with the saved HTML shared, others will be able to open the HTML in their own browser and look at the HTML structure precisely. Then somebody would be able to give you some productive advices.
Thank you for sharing your mht file. I could open the web page on my PC.
After I looking at the page, I went back to your original post (to your original question). Also I had a look at your code. â Still I do not understand what you want to do.
You wrote: âI want to make this Search as Test Data Value which can be passed through data fileâ.
Possiblly what is called âData-driven testing approach in Katalon Studioâ is the answer to this particular question. Have a look at the following article, go through its instruction:
Katalon provides some more pages concerning âData driven testingâ. Google search will tell you the URLs.