Skip to content

Commit

Permalink
#143: Stabilize the SelenideAddonsTest
Browse files Browse the repository at this point in the history
improved code
  • Loading branch information
Marcel Pfotenhauer committed Oct 9, 2020
1 parent 54d2efc commit c553102
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/test/java/com/xceptance/neodymium/util/SelenideAddonsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xceptance.neodymium.util;

import static com.codeborne.selenide.Condition.attribute;
import static com.codeborne.selenide.Condition.exist;
import static com.codeborne.selenide.Condition.hidden;
import static com.codeborne.selenide.Condition.visible;
Expand Down Expand Up @@ -420,9 +421,9 @@ public void testRightwardDragAndDropUntilCondition()
openSliderPage();

SelenideElement slider = $(".balSlider a[role=slider]");
slider.shouldHave(attribute("aria-valuenow", "-10"));
SelenideAddons.dragAndDropUntilCondition(slider, slider, 40, 0, 3000, 23, Condition.attribute("aria-valuenow", "8"));

Assert.assertEquals("8", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "8"));
}

@Test()
Expand All @@ -431,9 +432,9 @@ public void testLeftwardDragAndDropUntilCondition()
openSliderPage();

SelenideElement slider = $(".balSlider a[role=slider]");
slider.shouldHave(attribute("aria-valuenow", "-10"));
SelenideAddons.dragAndDropUntilCondition(slider, slider, -40, 0, 3000, 23, Condition.attribute("aria-valuenow", "-8"));

Assert.assertEquals("-8", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "-8"));
}

@Test()
Expand All @@ -442,9 +443,9 @@ public void testUpwardDragAndDropUntilCondition()
openSliderPage();

SelenideElement slider = $("#equalizer .k-slider-vertical:first-child a");
slider.shouldHave(attribute("aria-valuenow", "10"));
SelenideAddons.dragAndDropUntilCondition(slider, slider, 0, -10, 3000, 23, Condition.attribute("aria-valuenow", "16"));

Assert.assertEquals("16", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "16"));
}

@Test()
Expand All @@ -453,9 +454,9 @@ public void testDownwardDragAndDropUntilCondition()
openSliderPage();

SelenideElement slider = $("#equalizer .k-slider-vertical:first-child a");
slider.shouldHave(attribute("aria-valuenow", "10"));
SelenideAddons.dragAndDropUntilCondition(slider, slider, 0, 10, 3000, 23, Condition.attribute("aria-valuenow", "-6"));

Assert.assertEquals("-6", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "-6"));
}

@Test()
Expand All @@ -464,9 +465,9 @@ public void testLeftwardDragAndDropUntilAttribute()
openSliderPage();

SelenideElement slider = $(".balSlider a[role=slider]");
slider.shouldHave(attribute("aria-valuenow", "-10"));
leftHorizontalDragAndDropUntilAttribute(slider, slider, -40, "aria-valuenow", "-8");

Assert.assertEquals("-8", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "-8"));
}

@Test()
Expand All @@ -475,6 +476,8 @@ public void testDragAndDropAssertionError()
openSliderPage();

SelenideElement slider = $(".balSlider a[role=slider]");
slider.shouldHave(attribute("aria-valuenow", "-10"));

Assert.assertThrows(UIAssertionError.class, () -> {
SelenideAddons.dragAndDropUntilCondition(slider, slider, -10, 0, 3000, -1, Condition.attribute("aria-valuenow", "-16"));
});
Expand All @@ -486,8 +489,9 @@ public void testRightwardDragAndDrop()
openSliderPage();

SelenideElement slider = $(".balSlider a[role=slider]");
slider.shouldHave(attribute("aria-valuenow", "-10"));
SelenideAddons.dragAndDrop(slider, 32, 0);
Assert.assertEquals("2", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "2"));
}

@Test()
Expand All @@ -496,9 +500,9 @@ public void testLeftwardDragAndDrop()
openSliderPage();

SelenideElement slider = $(".balSlider a[role=slider]");
slider.shouldHave(attribute("aria-valuenow", "-10"));
SelenideAddons.dragAndDrop(slider, -32, 0);

Assert.assertEquals("-2", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "-2"));
}

@Test()
Expand All @@ -507,9 +511,9 @@ public void testDownwardDragAndDrop()
openSliderPage();

SelenideElement slider = $("#equalizer .k-slider-vertical:first-child a");
slider.shouldHave(attribute("aria-valuenow", "10"));
SelenideAddons.dragAndDrop(slider, 0, 12);

Assert.assertEquals("6", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "6"));
}

@Test()
Expand All @@ -518,9 +522,9 @@ public void testUpwardDragAndDrop()
openSliderPage();

SelenideElement slider = $("#equalizer .k-slider-vertical:first-child a");
slider.shouldHave(attribute("aria-valuenow", "10"));
SelenideAddons.dragAndDrop(slider, 0, -12);

Assert.assertEquals("14", slider.getAttribute("aria-valuenow"));
slider.shouldHave(attribute("aria-valuenow", "14"));
}

private void openSliderPage()
Expand All @@ -539,7 +543,7 @@ private void openSliderPage()
if (overlayIsVisible)
{
$("#onetrust-accept-btn-handler").click();
$("#onetrust-consent-sdk .onetrust-pc-dark-filter").waitUntil(hidden, Neodymium.configuration().selenideTimeout());
$("#onetrust-consent-sdk .onetrust-pc-dark-filter").shouldBe(hidden);
Selenide.refresh();
}
}
Expand Down

0 comments on commit c553102

Please sign in to comment.