RE: How to validate?
I was trying to select few products and adding them to cart/Bag and I want to verify the selected Products are same in the cart/Bag. Please let me know how to do it.
URL is: http://store.demoqa.com/products-page/product-category/
Note: What all items you are selecting those items should be in your shopping cart.
First of all thanks for aksing using ForumsQA, second many thanks for supporting us by giving solutions on asked questions, third congrats as i can pick up that you have learned alot in last few days and trying different scenarios & fourth good luck for your future.
Coming back to you question:
I think you got confused with Modular Driven & Page Object Model, as the above example you have given us is a part of Page Object model (POM). POM helps us to identify objects. Where as Modular Driven Framework (MDF) is something in which we combine the series of steps and rather calling the each of the steps one by one we just call that modular part.
Now, if we take the same example of our Framework, you can see that in the POM class of Product Listing Page , we are selecting product with the location of the product. Right, it is not with the product name. Means, what so ever is the first product, we will select that and like this we will select second as well. So that is the use of dynamic Page Objects.
I am happy to see that what you are trying to do here is something very userfull in test, which is verifying the product on Add to cart page. So to handle this you just need a simple trick or the way to handle the situation. There can two possible solutions to that:
First: Get the name of the first and second product by using some element.getText() or anything and store it in the same Excel file from which you are passing your other data. Once you add those product in to your cart, go to cart page, again get the name of the products from the cart page and compare the text name of the products from the Excel. Hope you get it what I am trying to say here.
Second: Create String variables on your main test script and store the name of the products on those variables and later you can easily compare the text of the variables with text of the Add to Cart page products name.
I am not intrested in giving you the code for it, as I know you would love to do this by your self.