How to select an item in the ListBox in Selenium Webdriver unordered (bulleted) list!!!!

Handling the Listbox in Selenium WebDriver in the below website http://www.cheapflights.com/ is shown below:







HTML <ul> Tag
The <ul> tag defines an unordered (bulleted) list.
Use the <ul> tag together with the <li> tag to create unordered lists.
References->http://www.w3schools.com/tags/tag_ul.asp
HTML Code for ListBox in http://www.cheapflights.com/: 
<ul class="ui-dropdown-list">
<li class="ui-dropdown-selected notranslate" data-value="">1</li>
<li class="notranslate" data-value="">2</li>
<li class="notranslate" data-value="">3</li>
<li class="notranslate" data-value="">4</li>
<li class="notranslate" data-value="">5</li>
<li class="notranslate" data-value="">6</li>
<li class="notranslate" data-value="">7</li>
<li class="notranslate" data-value="">8</li>
<li class="notranslate" data-value="">9</li>
</ul>
Selenium WebDriver Code For Selecting a Value from the ListBox:

import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class HandlingListbox {
 
 public static void main(String[] args) {
 WebDriver driver = new FirefoxDriver();
 driver.get("http://www.cheapflights.com/");
 driver.findElement(By.cssSelector("#sb-adults>div>.arrow")).click();
 List<WebElement> liList = driver.findElements(By.cssSelector(".ui-dropdown-list>li.notranslate"));
 liList.get(3).click(); 
 }

}

Output:

Internet Explorer Driver - Required Configuration IE 10,IE 11






Required Configuration

  • The IEDriverServer exectuable must be downloaded and placed in your PATH.
  • On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
  • Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
  • The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
  • For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor isHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

How to handle https security warning in IE for Selenium WebDriver + RC & How to solve the Unhandled exception: Modal dialog present







In Selenium Webdriver whenever we try to launch the IE we get the Security Warning pop-up.
Handling security warning pop-up can be done in two ways.

1. Using Robot Script as follows:
try {
        (new Robot()).keyPress(java.awt.event.KeyEvent.VK_ENTER);

         (new Robot()).keyRelease(java.awt.event.KeyEvent.VK_ENTER);
         } catch (AWTException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

2. Adding the website url in the Trusted websites
  1. Open Internet Explorer by clicking the Start button Picture of the Start button. In the search box, type Internet Explorer, and then, in the list of results, click Internet  Explorer.
  2. Navigate to the website that you want to add to a specific security zone.
  3. Click the Tools button, and then click Internet Options.
  4. Click the Security tab, and then click a security zone (Local intranetTrusted sites, or Restricted sites).
  5. Click Sites.
  6. If you clicked Local intranet in step 4, click Advanced.
  7. The website should be shown in the Add this website to the zone field. Click Add.
    If the site is not a secure site (HTTPS), clear the Require server verification (https:) for all sites in this zone check box.
  8. Click Close, and then click OK (or click OK twice if you clicked Local intranet in step 4).