2017-10-10 7 views
-3

これで選択オプションにアクセスできません。隠しタグの選択問題

<tooltip-component params="id:'title1',title:'Alert name should be unique',isImportant:true"></tooltip-c 
<br> 
<select class="chosen-select" data-placeholder="Alert Type" id="alert_type" data-bind="options:alertType,optionsText: 'name', optionsValue: 'id',chosenSelectedOptions: selected Alert,valueAllowUnset: true" ></select> 

このドロップリストを表示してアクセス可能にするにはどうすればよいですか?あなたはそれを見つけるためにIDを使用することができます

+0

利用Idは一度それを – iamsankalp89

答えて

0

このコードを試してみてください
Select dropdown= new Select(driver.findElement(By.id("alert_type"))); 
    dropdown.selectByVisibleText("Value under Dropdown");. 

また

Select dropdown= new Select(driver.findElement(By.xpath("//*[@id='alert_type']"))); 
    dropdown.selectByVisibleText("Value under Dropdown"); 
+0

TRY鉱山にアクセスするには、私はすべて試してみました可能 – iamsankalp89

0

XPathを使用することができます下記の回答のいずれかを試してみてください。

new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("alert_type"))); 
new Select(driver.findElement(By.id("alert_type"))).selectByVisibleText("Text Name Under Your Dropdown"); 

OR

new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("alert_type"))); 
new Select(driver.findElement(By.id("alert_type"))).selectByIndex(0); //Indexing start from zero 

OR

new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("alert_type"))); 
new Select(driver.findElement(By.id("alert_type"))).selectByValue("Value Name Under your Dropdown"); 
+0

場合はURLを共有してくださいのそれで、私はここに上陸しました... :( – Aitori

+0

ありがとう@ Jainish。 スレッド "main"の例外org.openqa.selenium.ElementNotVisibleException:要素が表示されず、要素が現在表示されていないため操作できない (セッション情報:chrome = 61.0.3163.100) (ドライバプラットフォーム:Windows NT 6.1.7601 SP1 x86)(警告:サーバーはスタックトレース情報を提供しませんでした) コマンドの継続時間またはタイムアウト:2.31秒 ビルドインフォメーション:バージョン: 'unknown' info:chromedriver = 2.29.461591(62ebf098771772160f391d75e589dc567915b233) 、改訂: '1969d75'、時間:'2016-10-18 09:43:45 -0700 ' – Aitori

+0

上記のエラーから、この要素に到達するまで数秒間待ってください。ドライバがWeb要素を見つけることができるかもしれません。待機用には '明示的待ち'メソッド。私は私の答えも更新しました。 –