2017-03-07 5 views
2

Wie scrolle ich im Dropdown-Fenster in selen webdriver nach unten?

<div id="boundlist-1277-listWrap" data-ref="listWrap" role="presentation" class="x-boundlist-list-ct x-unselectable x-no-touch-scroll x-scroll-container" style="overflow: auto; height: 298px;"> 
 
     <ul id="boundlist-1277-listEl" data-ref="listEl" class="x-list-plain x-scroll-scroller"> 
 
     <li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="0" data-recordid="99400" data-boundview="boundlist-1280">Assessment Completion - Returned To Functional Validation</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="1" data-recordid="99401" data-boundview="boundlist-1280">Assessment Completion - Workflow Ended</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="2" data-recordid="99402" data-boundview="boundlist-1280">Eligibility Assessment In Progress</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="3" data-recordid="99403" data-boundview="boundlist-1280">Functional Validation In Progress</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="4" data-recordid="99404" data-boundview="boundlist-1280">Functional Validation- Returned To Sponsor</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="5" data-recordid="99405" data-boundview="boundlist-1280">MEA - Workflow Ended</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="6" data-recordid="99406" data-boundview="boundlist-1280">Pending Assessment Completion</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="7" data-recordid="99407" data-boundview="boundlist-1280">Pending Eligibility Assessment</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="8" data-recordid="99408" data-boundview="boundlist-1280">Pending Pre-MEA</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="9" data-recordid="99409" data-boundview="boundlist-1280">Pending Technical Validation</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="10" data-recordid="99410" data-boundview="boundlist-1280">Pending Validation Planning</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="11" data-recordid="99411" data-boundview="boundlist-1280">Pre-MEA - Pending Sponsor Response</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="12" data-recordid="99412" data-boundview="boundlist-1280">Pre-MEA - Workflow Ended</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="13" data-recordid="99413" data-boundview="boundlist-1280">Pre-MEA in Progress</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="14" data-recordid="99414" data-boundview="boundlist-1280">Technical Validation - Returned To Sponsor</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="15" data-recordid="99415" data-boundview="boundlist-1280">Technical Validation - Workflow Ended</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="16" data-recordid="99416" data-boundview="boundlist-1280">Technical Validation In Progress</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item x-boundlist-item-over" tabindex="-1" data-recordindex="17" data-recordid="99417" data-boundview="boundlist-1280">Validation Finalized - Workflow Closed</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="18" data-recordid="99418" data-boundview="boundlist-1280">Validation Initiated - MDDT Upload In Progress</li> 
 
<li role="option" unselectable="on" class="x-boundlist-item" tabindex="-1" data-recordindex="19" data-recordid="99419" data-boundview="boundlist-1280">Validation Planning In Progress</li> 
 
     </ul> 
 
    </div>

Dropdown

Wie in einer Dropdown-Liste nach unten scrollen? Ich möchte einen Dropdown-Wert auswählen, der sich in der Dropdown-Liste befindet. Aber ich kann nicht direkt darauf klicken, indem ich den X-Pfad benutze, da der Wert in der Liste versteckt ist, für die ich zuerst runterscrollen muss.

Ich habe versucht, diesen Code mit

WebElement element = driver.findElement(By.xpath("//li[text()='Validation Finalized - Workflow Closed']")); 
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", element); 
Thread.sleep(500); 
+0

Warum Sie wollen nach unten scrollen? Haben Sie versucht, ausgewählte Klasse von Webdriver zu verwenden? – SelThroughJava

+0

Können Sie den HTML-Code Ihres Dropdown-Menüs teilen? –

+0

Haben den HTML-Code für das Dropdown-Menü freigegeben. Es enthält die Registerkarte div, daher kann die Klasse select nicht verwendet werden –

Antwort

0

Sie folgenden Code verwenden:

// Create an array of web element for all drop-down options 
List<WebElement> optionList = driver.findElements(By.xpath("//*[@id='boundlist-1277-listEl']/li")); 
// The option you mentioned in your example is stored at position #17 in an arrya so either you can manually enter the number or you can find it by running FOR lool 
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", optionList.get(17)); 

// Other ther way that I preffer is: 
JavascriptExecutor je = (JavascriptExecutor) driver; 
je.executeScrpt("arguments[0].scrollIntoView(true);", optionList.get(17)); 
Thread.sleep(250); 
Verwandte Themen