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
[("User_Email"): user_input , ("User_Password"): user_password ], FailureHandling.STOP_ON_FAILURE)
//Click on project main page
println('Project detail mode is displayed')
println("Couldn't find the Project Button")
//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.
//Set Project Name fetching from the file data
System.out.println("The entered Project name is : " + ProjectName)
// Declaring the variables
String GetProjectName, ProjectNotFoundMessag, Headingtext, CellText
//Calling the verification method here!!!!
ProjectNotFoundMessage, ProjectNotFoundMessag, Headingtext, CellText)
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.