2
0

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 3 years have passed since last update.

Selenium inputかbuttonか分からないボタンをクリック

Last updated at Posted at 2021-05-02

画面のマニュアルしか持っていなくてHTMLソースをまだ見れないうちに、ボタンクリック動作を書く方法です。ボタンがinputかbuttonか分からないので「|」で結合しています。idやnameがあるかどうかも分からないのでボタン名での記述です。
「|」の前後の半角スペースはあってもなくても動きます。

HTML.html
    <input type="submit" value="登録" />
または
    <button type="submit">登録</button>
C#.cs
    driver.FindElement(By.XPath("//input[@value='登録'] | //button[text()='登録']")).Click();
Java.java
    driver.findElement(By.xpath("//input[@value='登録'] | //button[text()='登録']")).click();
Python.py
    driver.find_element_by_xpath("//input[@value='登録'] | //button[text()='登録']").click()

2021/05/19追記:HTMLソースが見れるようになって見てみたらaタグだった…。

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?