I have a problem with my test script for 5 days now! I simply can’t find a simple button element - neither using $(ButtonElement.class).get(0), $(ButtonElement.class).first() nor using my Webdriver (ChromeDriver, newest version).
It always throws a NullpointerException. It’s curious that this detection works pretty fine before this test step. And I see the button, the scipt should be able to find it too!!! What coud be the reason, that makes a TestBenchTestCase forgetting his WebDriver and his implementation?
I’m ready to go spare and have no idea where to look for, please help me.
Thank you!
This is the code: (The method checks that a line in a GridElement element has disappeared after I combined it in a group. (implemented by my company) )
if (!shouldElementsBeInList) {
for (int numberOfActualRow = 0; numberOfActualRow < getGridRowCount(); numberOfActualRow++) {
String foundEntryName = getGridCellByIndex(numberOfActualRow, 1).getText();
String foundEntryVersion = getGridCellByIndex(numberOfActualRow, 2).getText();
boolean isThisEntryMatchingSearchedName = searchedEntryName.equals(foundEntryName);
boolean isThisEntryMatchingSearchedVersion = searchedEntryVersion.equals(foundEntryVersion);
boolean isThisSoftwareEntryInGridAnyway = isThisEntryMatchingSearchedName
&& isThisEntryMatchingSearchedVersion;
generalHelper.failWithThisErrorMessageIfThisConditionIsTrue(isThisSoftwareEntryInGridAnyway,
"Entry " + searchedEntryName + ";" + searchedEntryVersion
+ " has been found in list but should be in a group!");
At least I resolved the problem! The reason seemed to be the access to my ChromeDriver.
To avoid opening 5 browser windows I use one general driver in a helper class. In another helper class I initialized another new Chrome Driver (legacy code) that was null.
I didn’t know that this would take influence to ElementQueries like $(ButtonElement.class).all() etc.