代码之家  ›  专栏  ›  技术社区  ›  Rajasankar

如何在Selenium中使用DOM定位器

  •  1
  • Rajasankar  · 技术社区  · 16 年前

    我有这样的HTML源代码,

    <input type="image" onclick="return logSub();" src="/images/Login_submit.gif" width="105" height="33" border="0" />
    

    这里没有身份证和姓名。所以我只能使用图像索引(这是硬的)或使用SRC标记来定位它?但我不知道如何使用SRC标记?

    有可能吗?

    4 回复  |  直到 13 年前
        1
  •  1
  •   Rodreegez    16 年前

    或与CSS:

    css=input[type=image], [src="/images/Login_submit.gif"]

        2
  •  2
  •   Community Mohan Dere    8 年前

    请参阅我对上一个问题的回答: selenium: Is it possible to use the regexp in selenium locators

    基本上 dom= 协议允许您使用javascript来定位硒元素。

        3
  •  1
  •   Jansen Price    16 年前

    你试过了吗

    //input[@src='/images/Login_submit.gif']
    
        4
  •  1
  •   ЯegDwight kri    13 年前

    尝试此定位器:

    //input[contains(@src, 'Login_submit.gif')].