In Safari, I need to select an option from the drop-down list. below code works for all browsers except Safari on Mac OS. I am using Safari 10.1.1 with the selenium web driver version 3.3.1. I wrote code in Java. See code below -
webElement = findElement(field); if (webElement.isDisplayed()) { Select select = new Select(webElement); select.selectByVisibleText(value); }
You can try this code:
public void jsSelect(WebElement element, int index) { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].selectedIndex=" + index + ";", element); } public void jsSelect(WebElement element, String item) { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("const textToFind = '" + item + "';" + "const dd = arguments[0];" + "dd.selectedIndex = [...dd.options].findIndex (option => option.text === textToFind);", element); }
You can check if the code below works in Safari ..
WebElement dropdown = driver.findElement(By.xpath("//select[@id='profileItem_10536']")); Select sel = new Select(dropdown); sel.selectByVisibleText("Yes");
If the code doesn’t work in Safari and works in other browsers, let me know ...
Update:
Sierra, ( Apple). Selenium SafariDriver Safari 10.
:" SafariDriver ". "Safari API WebDriver. Safari 10 OS X El Capitan macOS Sierra, Safari . - Apple". :" Safaris WebDriver "
:
" SafariDriver ". "Safari API WebDriver. Safari 10 OS X El Capitan macOS Sierra, Safari . - Apple". :
" Safaris WebDriver "
, ,
"/USR//safaridriver"
, . https://webkit.org/blog/6900/webdriver-support-in-safari-10/ https://github.com/SeleniumHQ/selenium/issues/3145
, . .
Sierra 10,12.6 safari 11.0 , , .
selectByIndex(3) selectByValue("value"), selectByVisibleText("Yes");
: , .
Safari. element.type("") Selenium, Select.
Source: https://habr.com/ru/post/1678169/More articles:Использование FluentScheduler - ASP.NET Core MVC - asp.net-core-mvcInsights application error updating database - c #Highcharts - map data point limit - angularjsHow to get Bazel workspace rule attributes using aspects - bazelhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1678168/dart-cannot-assigna-type-with-generics-to-a-type-variable&usg=ALkJrhgzl3Y3s04wXYIgzDqR490lwtv3OgФайлы шаблонов Wordpress в подкаталоге - phprun-sonar-swift.sh with custom swiftlint.yml file - sonarlintWhen does the right shift operation >> shift the bit sign, and when not? - c ++R: row-wise dplyr :: mutate using a function that takes a row of a data frame and returns an integer - rR: Use dplyr :: mutate / dplyr :: to transmute a function that acts on the entire line - rAll Articles