Need your help with coding with selenium, java, TestNg

Hi everyone,
I’m a QA student, quite new in this field and I need some help in coding. I’ve got a task, using selenium, TestNg, and Java. The only things that I did well were to write the annotations of BeforeClass and AfterClass but the test itself is too hard for me.
I’m required to do the following steps (which I’m not sure how to do) on a demo website and I’ll be grateful for your help.
a. To verify the price of a certain product (using assert),
b. To write my first name and last name in a form so I can order the product.
c. To choose from the Combo Box the Delivery option,
d. Check that the price has been changed (with the addition of the delivery),
e. There’s a coupon number that I need to print in the Additional Comments Field.
f. Click the button “Submit Your Order”.
g. An alert window will pop up and will present my first&last name&the coupon number.
h. I’ll need to close the alert window,
i. Close the HTML website.

I appreciate your help!
Best regards,
Liat

What do you have so far? It would be easier to help if we could see the implementation class and the test class (so far).

Not sure we will have lots of experience among the students with all of the parts here, but that is minimally what we would need to be able to help here. Are you able to do any of the steps or do you need help with all of them? If you can focus in on specific questions you need answers to that makes it easier for others on this forum to help.

Thanks for your response.
I need help with all the aspects that I mentioned in the message.
It won’t help to show you the task because it’s in Hebrew.
Liat

Let me be clear: it is nearly impossible to help without more information. At a minimum we would need to see the implementation class (or its interface) that you are testing so that we know what the API looks like to be able to write a test for it. Without something like that it is meaningless to ask “To verify the price of a certain product (using assert)” for example.

NOTE: I am asking for the Java code you are testing, not the description of the task. Presumably the code itself is in English.

Hi Jason,
I appreciate your help alot!!!
I’ll take a picture of what I’ve done so far in Java. But I’m not sure I did it properly, though.
Take a look at it and I’ll write to you the instructions I need to follow in order to solve this out.
Best regards,
Liat

בתאריך יום ב׳, 29 באוג׳ 2022, 01:23, מאת Jason Runkle via Code with Mosh Forum ‏<notifications@codewithmosh.discoursemail.com>:

Well, is it possible to have a zoom meeting ? so we can do it together?

‫בתאריך יום ב׳, 29 באוג׳ 2022 ב-19:11 מאת ליאת בן דוד זילבר <‪lbdz2013@gmail.com‬‏>:‬

I couldn’t attach a pic here. So if it’s possible to meet on zoom, that would be great.

It sounds like you have a challenging but exciting task ahead in your QA journey. To help you with your task using Selenium, TestNG, and Java, here’s a brief guide on how to approach each step:

a. Verifying Product Price (Using Assert): You can locate the element that displays the product price on the website, extract its value, and use TestNG’s Assert class to verify it against the expected price.

b. Entering First Name and Last Name in a Form: Locate the form fields for first name and last name, then use Selenium to sendKeys() to input your first and last names.

c. Choosing Delivery Option from Combo Box: Locate the combo box element and select the desired delivery option using Selenium’s Select class.

d. Checking Price with Delivery: Recalculate the total price with the added delivery cost and verify it as you did in step a.

e. Entering Coupon Number in Additional Comments Field: Locate the additional comments field and use Selenium to input the coupon number.

f. Clicking “Submit Your Order” Button: Find the “Submit Your Order” button element and use Selenium’s click() method to submit your order.

g. Handling Alert Window: Use Selenium’s alert handling functions to capture the alert, extract the text (which should include your first name, last name, and coupon number), and then close the alert.

h. Closing Alert Window: You’ve already handled this in step g.

i. Closing the HTML Website: After completing all the steps, you can close the web browser using Selenium’s close() method.

Remember to use appropriate WebDriver methods to locate and interact with web elements on the page (e.g., findElement, sendKeys, click, etc.). Break down your task into smaller, manageable steps, and gradually build your test script. Don’t hesitate to reach out for specific code examples or further assistance if needed. Good luck with your task!