mercredi 18 avril 2018

Two versions of the same locator in automation testing: one works, the other causes numerous errors

There is a list box that contains three options: "In Progress", "Complete", and "Clear Status".

When I call:

page_object.zs_out_btn(driver).click();
new Select(page_object.zs_out_btn(driver)).selectByVisibleText("In Progress");

...this works perfectly. This clicks the dropdown button, and selects 'In Progress'.

After this is where I start having issues. I have two versions of the same thing I am trying select in the sense that one works and the other doesn't; I am not running both of these at the same time.

page_object.zs_out_btn(driver).click();
//new Select(page_object.zs_out_btn(driver)).selectByVisibleText("Complete");
//new Select(driver.findElement(By.id("zs-status-select"))).selectByVisibleText("Complete");

The second line doesn't work. The third line does. I used Katalon and two other tools to verify that this path is indeed valid. They even work inside of those tools and despite hundreds of attempts at sampling this, it always gives this id. byClass couldn't be found even through manual definition. The HTML for this looks like this:

<select id="zs-status-select" class="form-control" style=""><option>In Progress</option><option>Complete</option><option value="">Clear Status (Blank)</option></select>

The way that I defined the second line in POM is such:

public WebElement zs_out_btn(WebDriver driver) {
        element = driver.findElement(By.id("zs-outpost-select"));
        return element;
    }

What I am seeing is that TestNG doesn't report this as a failure and goes directly to my @AfterTest. So I disabled this to see if it would just hang on that element and it did. I tried implicit, explicit, and even a thread.sleep(I know I'm not supposed to use this, it is only for testing) waits to make sure everything on page was loaded and to give the driver time to find it.

Depending on how many times I run this, every now and then it will work, sometimes the browser will just time out and quit on its own even with the @AfterTest disabled, sometimes eclipse oxygen will freeze and give some errors that I've never seen before then quit. After restarting eclipse numerous times, it will start to work and then come back to the same issue I am having.

So, I reinstalled eclipse, rebuilt the project from scratch, three times, included the correct libraries for selenium and TestNG. Same behavior. I am able to run all my other tests perfectly fine.

Why is this particular element, so troublesome and why would it force the browser or eclipse to time out and close? Any help with this would be very much appreciated.

Aucun commentaire:

Enregistrer un commentaire