How to select a dynamic value in select2 dropdown for selenium
问题 I am writing a test where data needs to be selected from a select2 drop down. Ajax call is fetching the data which can change according to scenario. My solution works if i enter a hard coded value but that solution is not feasible for me driver.findElement(By.id("select2-company-container")).click(); WebElement dropdown=driver.findElement(By.xpath("//ul[@id='select2-company-results']")); driver.findElement(By.className("select2-search__field")).sendKeys("Einstein"+ Keys.ENTER); I have tried