Caleb Caleb - 1 year ago 98
Javascript Question

Cannot select hidden element in drop down list in Protractor

In my website I have a drop down list containing 50 data in the list. So, I'm going to write Protractor test script for read the final value in the list.

I've tried following code segment for drop down list.

element.all(by.model('salary_generate.company_id')).each(function (eachElement, index)
element(by.value('ESOFT Technologies (Pvt) Ltd.')).click();

This test fails.

Answer Source

Use following code. :)

// Create instance of Javascript executor
JavascriptExecutor je = (JavascriptExecutor) driver;
//Identify the WebElement which will appear after scrolling down
WebElement element = driver.findElement(By.tagName("...."));
// now execute query which actually will scroll until that element is not appeared on page.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download