I am using Selenium Webdriver with appium to automate mobile web application in iOS simulator. I am unable to select the value from drop down box using the below code.
Select dropdownbox = new Select(driver.findElement(By.id("alertType"));
dropdownbox.selectByVisibleText("Alert");
Below is the html of the drop down box which is having javascript function “onchange”
Above selenium webdriver code working perfectly in all browsers but it is not able to select value in iOS simulator. Is this because of drop down having ‘onchange’ javascript function? Can any one provide the solution for this problem?
I have tried clicking the drop down and tried to click on the option element using xpath “//option[text()=‘Alert’]”, But it is not clicking the specific option.
Select d1 = new Select(dropdown); d1.selectByVisibleText(“Alert”);
But both are not working. This problem is only for iOS Simulator. It is working perfectly with all browsers.
Can anyone help me in this who are faced the similar issue and solved the problem?
I have observed that any element which triggers javascript function, webdriver is unable to perform operation on that element, I have found same issue with radio button in another page of my web application which triggers javascript function upon selecting the radio button, below is the html of the radio button.
org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript.
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.20 seconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'xxxxxxxx', ip: '1.1.2.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.1', java.version: '1.7.0_79'
Session ID: 8ee0d625-5d36-4734-b7e8-e7a9b9590546
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Below is the code i am using:-
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "iPad 2");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.4");
capabilities.setCapability("browserName", "Safari");
capabilities.setCapability("nativeWebTap", true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
//Create an instance of RemoteWebDriver and connect to the Appium server.
driver = new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), capabilities);