1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SelenideでInvalidSelectorException: invalid selectorエラーが出る

Posted at

はじめに

Selenideのエラーの切り分けに時間がかかり解決が大変だったので簡単にまとめます

問題

以下のようなコードを書いたところ

    private fun SelenideElement.coffeeCard(indexPlus1: Int): SelenideElement = this.`$`("div[data-test-id='card'])", indexPlus1 - 1)

以下のエラーが発生しました

Message: org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified
  (Session info: chrome=114.0.5735.90)

解決方法

以下のコードでうまく行きました

    private fun SelenideElement.coffeeCard(indexPlus1: Int): SelenideElement = this.`$`("div[data-test-id='card']", indexPlus1 - 1)
"div[data-test-id='card'])" ☓
"div[data-test-id='card']" ○

とういような違いがあり、ケアレスミスがあったことがわかりました

おわりに

Selenide自体の使い方が問題あるのかと思っていたのですが、簡単なミスでした

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?