Skip to content

Commit

Permalink
selenide#2551 Use fallback if JavascriptException occurs.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BorisOsipov authored and asolntsev committed Nov 16, 2023
1 parent 2e95fe5 commit ee221d9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -20,7 +21,7 @@ public List<String> texts(Driver driver, List<WebElement> elements) {
".replace(/[\\u200b\\u200e\\u200f]/g, '')" +
".trim())", elements);
}
catch (UnsupportedCommandException javascriptNotSupported) {
catch (UnsupportedCommandException | JavascriptException cannotUseJs) {
return textsOneByOne(elements);
}
}
Expand All @@ -41,7 +42,7 @@ public List<String> attributes(Driver driver, List<WebElement> elements, String
elements, attributeName
);
}
catch (UnsupportedCommandException javascriptNotSupported) {
catch (UnsupportedCommandException | JavascriptException cannotUseJs) {
return attributesOneByOne(elements, attributeName);
}
}
Expand Down

0 comments on commit ee221d9

Please sign in to comment.