2017-04-05 48 views
0

我想單擊該選項列表中顯示該選項,但我不能這樣做。地理組是過濾器,除此之外,您可以看到下拉圖標,點擊該圖標後,我應該可以看到兩個選項,即'APAC Delivery Center''GU'。我附上了圖片。
enter image description here下拉不工作在硒java

enter image description here

下面是我的UI代碼:

<div owner = "71"style="z-index: 666; left: 602px; top: 153px; width: 208px; height: 30px; position: absolute;"id="DS"class="QvFrame DS"> 
    <div style = "height: 28px; width: 206px;"class="QvContent"> 
    <div incontainer = "false"style="visibility: visible; position: relative; overflow: hidden; cursor: default; font-weight: normal; font-family: Arial; font-size: 8pt; font-style: normal; text-decoration: none; height: 28px; width: 206px;"objtype="Listbox"class="QvListbox"> 
    <div style="position: relative; overflow: hidden; width: 206px; height: 28px;"><div class="QvOptional" title="APAC Delivery Center" unselectable="on" style="text-align: left; font-style: normal; font-weight: normal; text-decoration: none; cursor: pointer; position: absolute; overflow: hidden; left: 0px; top: 0px; width: 206px; height: 14px;"> 
    <div unselectable = "on"style="position: absolute; z-index: 1; border-width: 0px 1px 1px 0px; border-style: solid; border-color: rgb(220, 220, 220); left: 0px; top: 0px; width: 205px; height: 13px;"></div> 
    <div title = "APAC Delivery Center"unselectable="on"style="padding: 0px; width: 206px; height: 14px; white-space: pre;"> 
    <div unselectable = "on"style="width: 2px; float: left; height: 14px; overflow: hidden; word-wrap: normal; white-space: pre;"></div> 
    <div unselectable = "on"style="width: 202px; float: left; height: 14px; overflow: hidden; word-wrap: normal; white-space: pre;"> 
    APAC Delivery Center</div></div></div> 
    <div class="QvOptional"title="GU"unselectable="on"style="text-align: left; font-style: normal; font-weight: normal; text-decoration: none; cursor: pointer; position: absolute; overflow: hidden; left: 0px; top: 14px; width: 206px; height: 14px;"> 
    <div unselectable = "on"style="position: absolute; z-index: 1; border-width: 0px 1px 1px 0px; border-style: solid; border-color: rgb(220, 220, 220); left: 0px; top: 0px; width: 205px; height: 13px;"></div> 
    <div title = "GU"unselectable="on"style="padding: 0px; width: 206px; height: 14px; white-space: pre;"> 
    <div unselectable = "on"style="width: 2px; float: left; height: 14px; overflow: hidden; word-wrap: normal; white-space: pre;"></div> 
    <div unselectable = "on"style="width: 202px; float: left; height: 14px; overflow: hidden; word-wrap: normal; white-space: pre;">GU</div></div></div></div> 
    <div style = "display: none; opacity: 1; right: auto; bottom: auto; transition-timing-function: cubic-bezier(0, 0.3, 0.6, 1); transition-property: -moz-transform; border-radius: 3px; width: 9px; height: 9px; background-color: rgb(221, 221, 221);"class="TouchScrollbar"></div> 

下面是我的下拉圖標代碼:

<div title="" class="cell-icon cell-ODDC-icon"></div> 

我嘗試使用下面的代碼,但還是我的問題是未解決:

driver.findElement(By 
        .xpath("//div[@class='QvGrid'][@style='position: absolute; border-left: 0px solid rgb(255, 255, 255); border-right: 2px solid rgb(210, 210, 210); border-bottom: 1px solid rgb(255, 255, 255); left: 0px; top: 0px; width: 11px; height: 13px;']")) 
        .click(); 

下面是我盡我所能來弄明白,因爲UI代碼它非常複雜:

<div objtype="Grid" objsubtype="MB" style="z-index: 68; top: 92px; left: 390px; width: 422px; height: 219px; border-radius: 7px; border: 1px solid rgb(232, 232, 232);" id="180" class="QvFrame Document_MB18"> 
<div style="height: 217px; width: 420px; border-radius: 6px; background-color: rgb(255, 255, 255); overflow: visible;" class="QvContent"> 
<div incontainer="false" style="position: relative; overflow: hidden; cursor: default; font-weight: normal; font-family: Arial; font-size: 8pt; font-style: normal; text-decoration: none; width: 420px; height: 217px;" class="QvGrid"> 
<div style="position: relative; overflow: hidden; width: 408px; height: 205px;"> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; width: 0px; height: 0px;"> 
<div class="page" page="0" style="position: absolute; height: 100%; transform: translate(0px, 0px);"></div></div> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; width: 0px; height: 205px;"> 
<div class="page" page="0" style="position: absolute; height: 224px; transition-timing-function: cubic-bezier(0, 0.3, 0.6, 1); transition-property: -moz-transform; transition-duration: 0ms; transform: translate(0px, 0px);"></div></div> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 205px; width: 0px; height: 0px;"> 
<div class="page" page="0" style="position: absolute; height: 100%; transform: translate(0px, 0px);"></div></div> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; width: 408px; height: 0px;"> 
<div class="page" page="0" style="position: absolute; height: 100%; transition-timing-function: cubic-bezier(0, 0.3, 0.6, 1); transition-property: -moz-transform; transition-duration: 0ms; transform: translate(0px, 0px);"></div></div> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; width: 408px; height: 205px;"> 
<div class="page" page="0" style="position: absolute; height: 224px; transition-timing-function: cubic-bezier(0, 0.3, 0.6, 1); transition-property: -moz-transform; transition-duration: 0ms; transform: translate(0px, 0px);"> 
<div unselectable="on" style="background-color: rgb(255, 255, 255); color: rgb(54, 54, 54); text-align: left; font-style: normal; font-weight: normal; text-decoration: none; cursor: pointer; position: absolute; overflow: hidden; left: 0px; top: 0px; width: 198px; height: 14px;" title="Geographic Group"> 
<div unselectable="on" style="position: absolute; border-right: 1px solid rgb(255, 255, 255); border-bottom: 1px solid rgb(255, 255, 255); left: 0px; top: 0px; width: 197px; height: 13px;"></div> 
<div class=" injected" style="padding: 0px 2px; width: 194px; height: 14px;"> 
<div title="Geographic Group" unselectable="on" style="width: 194px; white-space: pre; overflow: hidden; word-wrap: normal;">Geographic Group</div></div></div> 
<div unselectable="on" style="background-color: rgb(255, 255, 255); color: rgb(54, 54, 54); text-align: left; font-style: normal; font-weight: normal; text-decoration: none; cursor: pointer; position: absolute; overflow: hidden; left: 198px; top: 0px; width: 13px; height: 14px;" title=""> 
<div unselectable="on" style="position: absolute; border-left: 0px solid rgb(255, 255, 255); border-right: 2px solid rgb(210, 210, 210); border-bottom: 1px solid rgb(255, 255, 255); left: 0px; top: 0px; width: 11px; height: 13px;"></div> 
<div class=" injected" style="padding: 0px 2px; width: 9px; height: 14px;"><div style="width: 9px;"><div class="Qv_CellIcon_right" style="width: 14px; height: 13px; max-width: 9px; max-height: 13px;"><div title="" class="cell-icon cell-ODDC-icon"></div></div></div></div></div><div unselectable="on" style="background-color: rgb(248, 248, 248); color: rgb(54, 54, 54); text-align: center; font-style: normal; font-weight: normal; text-decoration: none; cursor: pointer; position: absolute; overflow: hidden; left: 211px; top: 0px; width: 208px; height: 14px;" title=""> 

即使我不能夠點擊該下拉菜單圖標,然後也將這樣做。我可以點擊那個地理組的那個空白區域,仍然會顯示選項列表。對於空白區域,我檢查
UI代碼:

<div unselectable="on" style="position: absolute; border-left: 0px solid rgb(210, 210, 210); border-bottom: 1px solid rgb(210, 210, 210); left: 0px; top: 0px; width: 208px; height: 13px;"></div> 

請幫我解決這個問題,或者如果您需要更多這方面的透明度,請讓我知道。感謝提前:)

+0

哪一個是一個下拉,我可以看到3個不同的東西 – kushal

+0

我看不到任何東西與你的HTML class'QvGrid'這是你從上面粘貼的HTML錯過的東西,還是xpath中的錯誤? – Jsmith2800

+0

我編輯了我的問題。請通過它,如果需要更清晰,請讓我知道 –

回答

0

謝謝大家對我的幫助,但我用下面的代碼解決了我的答案是:

driver.findElement(By 
        .xpath("//div[@unselectable='on'][@style='position: absolute; border-left: 0px solid rgb(210, 210, 210); border-bottom: 1px solid rgb(210, 210, 210); left: 0px; top: 0px; width: 208px; height: 13px;']")) 
        .click(); 
      Thread.sleep(5000); 
      driver.findElement(By 
        .xpath("//div[@unselectable='on'][@style='position: absolute; z-index: 1; border-width: 0px 1px 1px 0px; border-style: solid; border-color: rgb(220, 220, 220); left: 0px; top: 0px; width: 205px; height: 13px;']")) 
        .click(); 
0

如果你想從下拉式的一些值,則利用Select class

Select drp = new Select("xpath of dropdown"); 
Thread.sleep(5000); 
drp.selectByVisibleText("value to be selected from dropdown"); 

這裏我假設這是你的下拉<div title="" class="cell-icon cell-ODDC-icon"></div>的路徑。如果這是對的,那麼你可以寫這樣的東西。

通過driver.findElement(By.xpath("//div[@unselectable='on'][@style='position: absolute; border-left: 0px solid rgb(210, 210, 210); border-bottom: 1px solid rgb(210, 210, 210); left: 0px; top: 0px; width: 208px; height: 13px;']"))值替換的XPath下拉APAC Delivery Center或任何你想GU從下拉列表中選擇

+0

如何做到這一點在我的情況?你能幫助我嗎?這將是非常有幫助 –

+0

你能否提供包含下拉路徑的html,並且請突出顯示它,因爲你提供的html不是很清楚,我的意思是我無法找到下拉的xpath,使用上面提供的html。 –

+0

您的解決方案沒有爲我工作,不點擊該區域或圖標。我已經更新了我的問題。請讓我知道你是否想要更多細節。其實用戶界面非常複雜,但我仍然努力嘗試 –