所有我對硒和編程都很新。我堅持讓網站自動化。我需要一些幫助,我可以如何找到並點擊基於文本幾個標籤到HTML代碼的元素。如何在Selenium中找到基於文本中幾個標籤的元素
我正在尋找在以下HTML代碼中包含文本TEXT DISPLAYED IN BROWSER
的元素。如果我在 <div id="appt-24175027" class="grid-row pointer">
上使用「通過ID查找元素」,我可以找到該元素,但問題是ID appt-24175027
動態更改。
在HTML代碼我正在尋找下...
1st ELEMENT/TEXT DISPLAYED IN BROWSER
2nd ELEMENT/TEXT DISPLAYED IN BROWSER
3rd ELEMENT/Text DISPLAYED IN BROWSER
有人能指出我在正確的方向?
HTML:
<script type="text/javascript">
<script type="text/javascript">
<div id="content" class="content">
<div class="grid-container started">
<div id="started-block" class="grid-header pointer">
<div class="grid-header-icon">
<div class="icon-started">
<div class="inner"></div>
</div>
</div>
<div id="appt-24175027" class="grid-row pointer">
<div class="cell cell-content">
<div class="main-field">
<span style="color:#000000">TASK ACTIVE</span>
</div>
</div>
</div>
</div>
</div>
<div class="grid-container pending expanded">
<div id="pending-block" class="grid-header pointer">
<div class="grid-expander">
<div class="inner"></div>
</div>
<div class="grid-header-icon">
<div class="icon-pending">
<div class="inner"></div>
</div>
</div>
<div class="grid-header-title">Pending (5)</div>
</div>
<div id="pending-grid" class="grid-body">
<div id="appt-24181299" class="grid-row pointer">
<div class="cell appt-color" style="border-top: 1px solid rgb(255, 244, 0);border-right: 1px solid rgb(204, 177, 0); background: #FFDE00;"></div>
<div class="cell cell-content">
<div class="main-field">
<span style="color:#000000"></span>
</div>
</div>
</div>
<div id="appt-24180104" class="grid-row pointer">
<div class="cell appt-color" style="border-top: 1px solid rgb(255, 244, 0);border-right: 1px solid rgb(204, 177, 0); background: #FFDE00;"></div>
<div class="cell cell-content">
<div class="main-field">
<span style="color:#000000"> 1st ELEMENT/TEXT DISPLAYED IN BROWSER</span>
</div>
</div>
</div>
<div id="appt-24175024" class="grid-row pointer">
<div class="cell appt-color" style="border-top: 1px solid rgb(255, 224, 168);border-right: 1px solid rgb(204, 163, 122); background: #FFCC99;"></div>
<div class="cell cell-content">
<div class="main-field">
<span style="color:#000000"> 2nd ELEMENT/TEXT DISPLAYED IN BROWSER</span>
</div>
</div>
</div>
<div id="appt-24175025" class="grid-row pointer">
<div class="cell appt-color" style="border-top: 1px solid rgb(255, 224, 168);border-right: 1px solid rgb(204, 163, 122); background: #FFCC99;"></div>
<div class="cell cell-content">
<div class="main-field">
<span style="color:#000000">3rd ELEMENT/Text DISPLAYED IN BROWSER</span>
</div>
</div>
</div>
<div id="appt-24175026" class="grid-row pointer">
</div>
你能告訴哪些元素是你使用文本跨度或div或其他任何其他? –
正如我看到你的所有問題都不被接受,而提供的答案解決了你的問題..你需要[接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer工作)以及如果它幫助.. :) –