Wednesday: Firefox 47.0.2 + WebDriver 2.53.1

It is necessary in the registration form to select first the column "gender", then from the drop-down list, for example, "male". Non-working code:

package com.driver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Listdown { static WebDriver driver; public static void main(String[] args) { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.manage().window().maximize(); driver.get("https://accounts.google.com/SignUp?service=mail&hl=ru&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fpc%3Dtopnav-about-ru"); driver.findElement(By.xpath("(//strong[text()='Пол']/following-sibling::div/div[@role='listbox'])[1]")).click(); driver.findElement(By.xpath("//div[text()='Мужской']/parent::div[@role='option']")).click(); } } 

The method of clicking on the element "Male" does not work. The xpath path to the element in FirePath highlights correctly. For verification, I deduced the value of the item I searched for in the console (I changed the code a bit through WebElement) - the word “Male” is output to the console as expected:

 WebElement gender = driver.findElement(By.xpath("(//strong[text()='Пол']/following-sibling::div/div[@role='listbox'])[1]")); gender.click(); WebElement genderChose = driver.findElement(By.xpath("//div[text()='Мужской']/parent::div[@role='option']")); System.out.println(genderChose.getText()); 

The reason why the click () method does not work is not clear.

I experimented on the site OK.ru. By dancing with tambourines, I managed to select an item from the drop-down list, but only with the use of Actions and double-click doubleClick () on an element, the single-click method click () still won't work in this code:

 package com.driver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; public class Listdown { static WebDriver driver; public static void main(String[] args) { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.manage().window().maximize(); driver.get("https://ok.ru/dk?st.cmd=anonymMain&st.registration=on"); selectOpt("Country", "Albania"); } public static void selectOpt (String name, String option) { driver.findElement(By.xpath(String.format("//label[text()='%s']/parent::span/following-sibling::div", name))).click(); Actions builder = new Actions(driver); WebElement elemOption = driver.findElement(By.xpath(String.format("//*[@id='country']/option[text()='%s']", option))); builder.doubleClick(elemOption).perform(); } } 

What could be the reason for this?

    1 answer 1

    The issue was solved by reinstalling the new version of the web driver.