2017-03-16 42 views
1

您好我有以下代碼MD-選項硒蟒蛇,失敗的大部分時間

<md-option ng-repeat="sector in allSector | orderBy:'name'" ng-value="{"id":239,"name":"MU-BHND-JC32-0033","regionInventory":{"id":18,"regionName":"Mumbai","zone":{"id":4,"name":"WEST","longitude":73.1812,"country":{"id":3,"name":"INDIA","countryCode":"IND"},"latitude":22.3072},"stateCode":"MU","latitute":19.076,"longitude":72.8777},"latitute":19.29117616,"longitude":73.04375901,"coordinates":null,"centroid":null}" tabindex="0" class="ng-scope md-ink-ripple" role="option" aria-selected="false" id="select_option_982" aria-checked="true" value="[object Object]" style> 

基本上我想要選擇從上面的代碼元素MU-BHND-JC32-0033並點擊它。

由於id不斷變化,我不打開去id。

如果有人可以幫助我點擊使用xpath和ng-value。

我嘗試以下,但它未能

subRegOpt = driver.find_element_by_xpath("//md-option[@ng-value='MU-BHND-JC32-0033']") 
sleep(5) 
subRegOpt.click() 
+0

回答

0

嘗試更換

subRegOpt = driver.find_element_by_xpath("//md-option[@ng-value='MU-BHND-JC32-0033']") 

subRegOpt = driver.find_element_by_xpath("//md-option[contains(@ng-value, 'MU-BHND-JC32-0033')]") 
+0

非常感謝, –