Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch from the menu using Selenium webdriver
    primarykey
    data
    text
    <p>I'm a newbee, After entering the username/password I have an option to select a 'test' option. the first option is shown on the screen and next to it the drop down arrow. On clicking the arrow or box. A new box opens with the options to select (Test 1(default), test 2, test 3 and test4). I need to select based on the paramater set in a variable. I'm able to select the exact option by xpath settings but not been successful in using a variable to select.</p> <p>The drop down is custom box - highlights the selection when mouse hovers it.</p> <p>Thanks in advance</p> <p><strong>Following is the HTML code.</strong> </p> <pre><code>&lt;div id="loginForm:selectProject_panel" class="ui-selectonemenu-panel ui-widget-content ui-corner-all ui-helper-hidden ui-shadow" style="width: 208px; display: none; top: 58px; left: 617.5px;"&gt; &lt;div class="ui-selectonemenu-items-wrapper" style="height:auto"&gt; &lt;ul class="ui-selectonemenu-items ui-selectonemenu-list ui-widget-content ui-widget ui-corner-all ui-helper-reset"&gt; &lt;li class="ui-selectonemenu-item ui-selectonemenu-list-item ui-corner-all" data-label="Test 1 "&gt;Test 1&lt;/li&gt; &lt;li class="ui-selectonemenu-item ui-selectonemenu-list-item ui-corner-all" data-label="Test 2 "&gt;Test 2 &lt;/li&gt; &lt;li class="ui-selectonemenu-item ui-selectonemenu-list-item ui-corner-all ui-state-highlight" data-label="Test 3"&gt;Test 3&lt;/li&gt; &lt;li class="ui-selectonemenu-item ui-selectonemenu-list-item ui-corner-all" data-label="Test 4"&gt;Test 4&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>WebDriver code</p> <pre><code>WebElement username = driver.findElement(By.id("loginForm:userLoginId")); username.sendKeys("username"); WebElement endKeys("Password1!"); WebElement dropdown = driver.findElement(By.xpath(".//*@id='loginForm:selectProject_label']")); dropdown.click(); // System.out.println(); driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS); WebDriverWait waitForOptions = new WebDriverWait(driver,3); waitForOptions.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='loginForm:selectProject']/div[3]"))); driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS); WebElement option = driver.findElement(By.xpath(".//*[@id='loginForm:selectProject_panel']/div/ul/li[3]")); option.click(); System.out.println("Selecting Test 3"); WebElement button = driver.findElement(By.id("loginForm:loginButton")); button.click(); System.out.println(driver.getTitle()); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload