Home > database >  Angular automated testing using Selenium Java
Angular automated testing using Selenium Java

Time:05-19

I'm looking for some advice. I'm currently trying to create end-to-end test using selenium (Java) for an angular application. I don't think I need to mention how much of a pain this process has been because of the dynamic elements on the page.

I have looked at using NgWebDriver. But I have a problem with this approach. All of my elements on the page look like this:

<button _ngcontent-tmh-c54="" id="addNewPartnerSystem" pbutton="" label="Add New Partner System" type="button" ><span >Add New Partner System</span></button>

I have tried using the id's provided by the developers, in this case "addNewPartnerSystem", but selenium shows no element found error.

Any help would be greatly appreciated. Thank you!

CodePudding user response:

Since your page is rendered dynamically and assuming your XPath for the selection is correct, you need to wait until the page is loaded. Thread.sleep(milliseconds) will do the trick.

CodePudding user response:

You have try the below solutions

import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

elem = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("Xpath")));
elem.click();

OR

WebElement element = driver.findElement(By.id("id"));

JavascriptExecutor executor = (JavascriptExecutor)driver;

executor.executeScript("arguments[0].click();", element);

Let me know if this does not work for you

  • Related