我很难为以下代码构建x路径

时间:2019-01-28 11:29:23

标签: selenium-webdriver xpath

我很难为以下代码构造x路径:

<div class="selectize-input items not-full has-options"><input type="select-one" autocomplete="off" tabindex="" id="srclang-selectized" placeholder="Type source language *" style="width: 151.109px; opacity: 1; position: relative; left: 0px;"></div>

<select name="srclang" id="srclang" data-placeholder="Type source language *" class="form-control1 selectized" tabindex="-1" style="display: none;"><option value="" selected="selected"></option></select>

我可以知道如何为此构造x路径吗?

2 个答案:

答案 0 :(得分:0)

尝试以下xpath(如果无法使用ID选择元素):

driver.findElement(By.xpath("//input[contains(@placeholder,'Type source language')]"))

答案 1 :(得分:0)

请在xpath下尝试。我确信它会起作用。

driver.findElement(By.xpath(“ // input [@ id =” srclang-selectized“]”)))

请让我知道您对此的答复。