Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented selenium automation tests for all functionalities #1533

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TodorovskiMarko
Copy link

No description provided.

@pivotal-cla
Copy link

@TodorovskiMarko Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@TodorovskiMarko Thank you for signing the Contributor License Agreement!

@dsyer
Copy link
Member

dsyer commented May 16, 2024

Is it necessary to add TestNG in order to have Selenium tests? If not, would it be better to stick with JUnit, the same as the rest of the project?

@TodorovskiMarko
Copy link
Author

Is it necessary to add TestNG in order to have Selenium tests? If not, would it be better to stick with JUnit, the same as the rest of the project?

Yes, you are right, I reimplemented it. While I was learning Selenium, I used TestNG and was familiar with it, so that's why I initially used it on this project.

@Vigrind
Copy link

Vigrind commented May 16, 2024

I have some suggestions:
In TestBase when driver options are created, add the "--lang=en" argument. This way, if the test is started from a non-English language driver there will be no problems.
Also change "--headless" to ""--headless=new" for the ChromeOptions, here the reference: https://www.selenium.dev/blog/2023/headless-is-going-away/

Change the isPetNameDisplayed function in OwnerPage to something like:

	public boolean isPetNameDisplayed(String petName) {
		// FIX: petDetailsText need to be a list of string and not a normal String
		List<WebElement> petDetails = driver.findElements(petDetailsClass);
		List<String> petDetailsText = new ArrayList<>(petDetails.size());

		for (WebElement petItem : petDetails) {
			petDetailsText.add(petItem.getText());
		}

		String expectedPetName = input.getProperty(petName);

		for (String petDetailsItem : petDetailsText) {
			if (petDetailsItem.contains(expectedPetName))
				return true;
		}

		return false;
	}

driver.findElements(petDetailsClass) returns a list of elements, not 1
Sorry for my english end happy coding <3

@dsyer
Copy link
Member

dsyer commented May 17, 2024

Yes, you are right, I reimplemented it. While I was learning Selenium, I used TestNG and was familiar with it, so that's why I initially used it on this project.

Thanks. Can you make sure to run the build locally to check for failures? It just needs a formatter to be applied I think.

@TodorovskiMarko
Copy link
Author

I have some suggestions: In TestBase when driver options are created, add the "--lang=en" argument. This way, if the test is started from a non-English language driver there will be no problems. Also change "--headless" to ""--headless=new" for the ChromeOptions, here the reference: https://www.selenium.dev/blog/2023/headless-is-going-away/

Change the isPetNameDisplayed function in OwnerPage to something like:

	public boolean isPetNameDisplayed(String petName) {
		// FIX: petDetailsText need to be a list of string and not a normal String
		List<WebElement> petDetails = driver.findElements(petDetailsClass);
		List<String> petDetailsText = new ArrayList<>(petDetails.size());

		for (WebElement petItem : petDetails) {
			petDetailsText.add(petItem.getText());
		}

		String expectedPetName = input.getProperty(petName);

		for (String petDetailsItem : petDetailsText) {
			if (petDetailsItem.contains(expectedPetName))
				return true;
		}

		return false;
	}

driver.findElements(petDetailsClass) returns a list of elements, not 1 Sorry for my english end happy coding <3

Thank you for the suggestions. I updated the driver options. For the isPetNameDisplayed function, I used Java Streams to make the code more concise and readable.

@TodorovskiMarko
Copy link
Author

Yes, you are right, I reimplemented it. While I was learning Selenium, I used TestNG and was familiar with it, so that's why I initially used it on this project.

Thanks. Can you make sure to run the build locally to check for failures? It just needs a formatter to be applied I think.

I've applied the formatter. The build was successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants