From ee221d999c2b230417a8dfb8489be354ed15c2cf Mon Sep 17 00:00:00 2001 From: Boris Osipov Date: Thu, 9 Nov 2023 16:10:12 +0300 Subject: [PATCH] #2551 Use fallback if JavascriptException occurs. On webkit(safari), when you pass a list of WebElements to executeJavaScript(), you cannot get a property of any element in the list.For example, Array.from(arguments[0])[0].innerText will always be null. --- .../com/codeborne/selenide/impl/WebElementCommunicator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/codeborne/selenide/impl/WebElementCommunicator.java b/src/main/java/com/codeborne/selenide/impl/WebElementCommunicator.java index 6c8232b9e7..9ec1378fb2 100644 --- a/src/main/java/com/codeborne/selenide/impl/WebElementCommunicator.java +++ b/src/main/java/com/codeborne/selenide/impl/WebElementCommunicator.java @@ -1,6 +1,7 @@ package com.codeborne.selenide.impl; import com.codeborne.selenide.Driver; +import org.openqa.selenium.JavascriptException; import org.openqa.selenium.UnsupportedCommandException; import org.openqa.selenium.WebElement; @@ -20,7 +21,7 @@ public List texts(Driver driver, List elements) { ".replace(/[\\u200b\\u200e\\u200f]/g, '')" + ".trim())", elements); } - catch (UnsupportedCommandException javascriptNotSupported) { + catch (UnsupportedCommandException | JavascriptException cannotUseJs) { return textsOneByOne(elements); } } @@ -41,7 +42,7 @@ public List attributes(Driver driver, List elements, String elements, attributeName ); } - catch (UnsupportedCommandException javascriptNotSupported) { + catch (UnsupportedCommandException | JavascriptException cannotUseJs) { return attributesOneByOne(elements, attributeName); } }