Open aleksslitvinovs opened 2 years ago
Run the following script
import static testUI.UIOpen.open; import static testUI.Utils.By.byCssSelector; import static testUI.elements.TestUI.E; import org.testng.annotations.Test; public class Testing { @Test public void test() { open("https://example.com"); var element = E(byCssSelector("p a")); element.waitFor(5).untilHasAttribute("random-atribute").equalTo(""); System.out.println("attribute value = " + element.getAttribute("random-atribute")); } }
Actual result: the test passes even though attribute value = null, equalTo("") does not throw any error and executes successfully
attribute value = null
equalTo("")
Expected result: the test should fail with an error that the attribute has not been found
Run the following script
Output
``` > Task :compileJava NO-SOURCE > Task :processResources NO-SOURCE > Task :classes UP-TO-DATE > Task :compileTestJava UP-TO-DATE > Task :processTestResources NO-SOURCE > Task :testClasses UP-TO-DATE > Task :test Aug 16, 2022 6:22:22 PM com.codeborne.selenide.impl.WebDriverThreadLocalContainer getAndCheckWebDriver INFO: No webdriver is bound to current thread: 1 - let's create a new webdriver Aug 16, 2022 6:22:22 PM com.codeborne.selenide.impl.FileHelper ensureFolderExists INFO: Creating folder: /Users/aleksslitvinovs/Desktop/bug/build/downloads/1660663342101_5352_1 Aug 16, 2022 6:22:23 PM io.github.bonigarcia.wdm.WebDriverManager resolveDriverVersion INFO: Using chromedriver 104.0.5112.79 (resolved driver for Chrome 104) Aug 16, 2022 6:22:23 PM io.github.bonigarcia.wdm.WebDriverManager exportDriver INFO: Exporting webdriver.chrome.driver as /Users/aleksslitvinovs/.cache/selenium/chromedriver/mac64/104.0.5112.79/chromedriver Starting ChromeDriver 104.0.5112.79 (3cf3e8c8a07d104b9e1260c910efb8f383285dc5-refs/branch-heads/5112@{#1307}) on port 3778 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Aug 16, 2022 6:22:25 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Aug 16, 2022 6:22:25 PM com.codeborne.selenide.webdriver.BrowserResizer adjustBrowserSize INFO: Set browser size to 1366x768 Aug 16, 2022 6:22:26 PM com.codeborne.selenide.webdriver.WebDriverFactory logBrowserVersion INFO: BrowserName=chrome Version=104.0.5112.79 Platform=MAC Aug 16, 2022 6:22:26 PM com.codeborne.selenide.webdriver.WebDriverFactory createWebDriver INFO: Selenide v. 5.20.0 Aug 16, 2022 6:22:26 PM com.codeborne.selenide.webdriver.WebDriverFactory logSeleniumInfo INFO: Selenium WebDriver v. 3.141.59 build time: 2018-11-14T08:17:03 Aug 16, 2022 6:22:26 PM com.codeborne.selenide.drivercommands.CreateDriverCommand createDriver INFO: Create webdriver in current thread 1: ChromeDriver -> ChromeDriver: chrome on MAC (d5cc3d42fb9ef2ad960ea55dffa56187) [INFO] 2022.08.16 18:22:26.684: Browser chrome attribute value = null BUILD SUCCESSFUL in 8s 2 actionable tasks: 1 executed, 1 up-to-date 18:22:27: Execution finished ':test --tests "Testing"'. ```Actual result: the test passes even though
attribute value = null
,equalTo("")
does not throw any error and executes successfullyExpected result: the test should fail with an error that the attribute has not been found