Skip to content

Commit d0f7f7f

Browse files
committed
Ensure cannot search for empty tag names
1 parent 735e31b commit d0f7f7f

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

java/client/src/org/openqa/selenium/By.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ public ByTagName(String tagName) {
259259
Require.argument("Tag name", tagName)
260260
.nonNull("Cannot find elements when the tag name is null."));
261261

262+
if (tagName.isEmpty()) {
263+
throw new InvalidSelectorException("Tag name must not be blank");
264+
}
265+
262266
this.tagName = tagName;
263267
}
264268

java/client/src/org/openqa/selenium/remote/RemoteWebDriver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ public class RemoteWebDriver implements WebDriver, JavascriptExecutor, HasInputD
104104
// multiple constructors and we occasionally add a new one, and `init`
105105
// may be overridden by the user
106106
{
107-
remotableBys.put(By.cssSelector("").getClass(), Mechanism.REMOTE);
108-
remotableBys.put(By.linkText("").getClass(), Mechanism.REMOTE);
109-
remotableBys.put(By.partialLinkText("").getClass(), Mechanism.REMOTE);
110-
remotableBys.put(By.tagName("").getClass(), Mechanism.REMOTE);
111-
remotableBys.put(By.xpath("").getClass(), Mechanism.REMOTE);
107+
remotableBys.put(By.cssSelector("a").getClass(), Mechanism.REMOTE);
108+
remotableBys.put(By.linkText("a").getClass(), Mechanism.REMOTE);
109+
remotableBys.put(By.partialLinkText("a").getClass(), Mechanism.REMOTE);
110+
remotableBys.put(By.tagName("a").getClass(), Mechanism.REMOTE);
111+
remotableBys.put(By.xpath("//a").getClass(), Mechanism.REMOTE);
112112
}
113113

114114
private ErrorHandler errorHandler = new ErrorHandler();

0 commit comments

Comments
 (0)