Safari Version: 11.0.2
MAC Version: 10.12.6 Mac OS Sierra
selenium-java Version: 3.5.3
Language: JAVA
Whenever I am running a selenium test on Safari Driver it hangs after running few steps (could not find specific pattern). Same test run file on IOS/Safari, Android/Chrome, MAC/Chrome.
Works fine you run test in debug/step by step. What could be the reason Safari not responding?
Here is code to simulate the issue. Safari hangs and could not click 'Continue Shopping'
public static void main(String[] args) {
SafariOptions safariOptions = new SafariOptions();
safariOptions.setUseCleanSession(true);
// safariOptions.setUseTechnologyPreview(true);
DesiredCapabilities safariCapabilities = DesiredCapabilities.safari();
safariCapabilities.setJavascriptEnabled(true);
safariCapabilities.setAcceptInsecureCerts(true);
safariCapabilities.setPlatform(Platform.MAC);
safariCapabilities.setCapability("platformName", Platform.MAC);
safariCapabilities.setVersion("11.2");
safariCapabilities.setBrowserName("safari");
safariCapabilities.setCapability(SafariOptions.CAPABILITY, safariOptions);
WebDriver safariDriver = new SafariDriver(safariCapabilities);
safariDriver.manage().window().maximize();
safariDriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
safariDriver.get("https://www.shoppersstop.com/");
waitFor(safariDriver, ExpectedConditions.elementToBeClickable(By.xpath("//a[#href='cart']")));
safariDriver.findElement(By.xpath("//a[#href='cart']")).click();
waitFor(safariDriver, ExpectedConditions.elementToBeClickable(By.xpath("//a[text()='Continue Shopping']")));
safariDriver.findElement(By.xpath("//a[text()='Continue Shopping']")).click();
}
public static <T> T waitFor(WebDriver safariDriver, ExpectedCondition<T> condition) {
return new FluentWait<WebDriver>(safariDriver).withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(500, TimeUnit.MILLISECONDS).until(condition);
}
Even the subj is dead I had the similar issue and the solution was to set
"Turn off display after" setting to "Never"
in
"Apple" > "Preferences" > "Energy Saver"
Related
I want to execute my appium testcases on real iOS device over wifi (without connecting via cable).
I have tried "Connect via network" option in Devices and Simulators. But its just launching the app and closing automatically. Testcase is not executing.Same testcase is executing correctly via cable(if passcode is turn off).
xCode verison = 10.1
device iOS verison = 12.4.2
#BeforeTest
public void applaunch() throws MalformedURLException {
dc.setCapability("platformName", "iOS");
dc.setCapability("deviceName", "My iPhone");
dc.setCapability("automationName", "XCUITest");
dc.setCapability("noReset", true);
dc.setCapability("xcodeOrgId", "HDYDHGKBDKGJG");
dc.setCapability("xcodeSigningId", "iPhone Developer");
dc.setCapability("platformVersion", "12.4.2");
dc.setCapability("useNewWDA", "true");
//dc.setCapability("reportDirectory", reportDirectory);
//dc.setCapability("reportFormat", reportFormat);
dc.setCapability("testName", testName);
dc.setCapability(MobileCapabilityType.UDID, "Vhduysshs9af42cad204240fdfgfdgdgyjdhdhgdf");
dc.setCapability("bundleId", "com.estapp.pro.apptest");
driver = new IOSDriver<IOSElement>(new URL("http://127.0.0.1:4723/wd/hub"), dc);
}
#Test
public void test() throws Exception{
driver.findElementByXPath("//*[#name='More']").click();// Click on More button
}
#AfterTest
public void CloseApp() {
driver.closeApp();
}
You need to go to xcode to enable the wifi "connect via network" checkbox.
Input this in your terminal
idevice_id -l
if you see the real device uuid appears , it means you are successful connecting with wifi. You can execute your script from here.
I have imported my selenium code from windows to mac and installed chromedriver for mac and updated systemproperty accordingly.but it is throwing exception and showing previously set path:
java.lang.IllegalStateException: The driver executable does not exist: /Users/Preet12/Desktop/Selenium/AddaStore/C:\Users\cp\Downloads\chromedriver_win32\chromedriver.exe
however the path in mac is : /Users/Preet12/Desktop/Selenium/AddaStore/chromedriver 2
it is showing path of window also i.e. C:\Users\cp\Downloads\chromedriver_win32\chromedriver.exe
Code:
public class WithTestNG
{
WebDriver driver;
#BeforeClass
public void StartBrowser()
{
System.setProperty("webdriver.chrome.driver","/Users/Preet12/Desktop/Selenium/AddaStore/chromedriver 2" );
driver = new ChromeDriver();
driver.manage().window().maximize();
}
Try Navigating to the folder containing chromedriver and run
"chmod +x chromedriver"
Trying to upgrade to Selenium 3.0 from Selenium 2.53. I can not put firefox in path, nor can put the gekodriver in path. I was using this in Selenium 2:
String firefoxLocation = System.getenv("ProgramFiles(X86)") + "\\Mozilla Firefox_42\\firefox.exe";
System.setProperty("webdriver.firefox.bin", firefoxLocation);
driver = new FirefoxDriver();
This worked perfectly. I upgraded to Selenium 3.0, installed firefox 49 and downloaded the latest geko. I now have this:
String firefoxLocation = System.getenv("ProgramFiles(X86)") + "\\Mozilla Firefox_49\\firefox.exe";
String gekoLocation = "..\\common\\geko\\gekodriver.exe";
System.setProperty("webdriver.firefox.bin", firefoxLocation);
System.setProperty("webdriver.firefox.marionette", gekoLocation);
driver = new FirefoxDriver();
Firefox opens to a blank window, then times out. I tried instead of setting webdriver.firefox.marionette, setting webdriver.geko.driver, but got the error that I must use "webdriver.geko.driver" (which I was using). How do I arrange it so I can specify a different firefox.exe location and a different gekodriver.exe location?
spelling wrong.
try this:
System.setProperty("webdriver.gecko.driver", gekoLocation);
use gecko instead of geko
I was trying to launch safari browser on real device(iPhone 4) using appium. but it is giving following error.
Unable to install [/var/folders/7_/fz8kyhyn2g97s1m9zylk50xc0000gq/T/11545-10782-1dp1wfm/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [fdaxxx76].
Error [Error: Command failed: /bin/sh -c /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id fda51be7184f865f02de4f4c6cb8fff760964e76 --bundle "/var/folders/7_/fz8kyhyn2g97s1m9zylk50xc0000gq/T/11545-10782-1dp1wfm/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app"
Below is my sample code:
DesiredCapabilities cap = new DesiredCapabilities();
private static WebDriver driver;
#BeforeTest
public void prep() throws MalformedURLException {
System.out.println("Script started");
cap.setCapability("platformName", "iOS");
cap.setCapability("platformVersion", "8.3");
cap.setCapability("deviceName", "iPhone4");
cap.setCapability("udid", "fda51be7184f865f02de4f4c6cb8fff760964e76");
cap.setCapability("browserName", "Safari");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
}
#Test
public void googleTest() {
System.out.println("main method");
driver.get("http://google.com");
}
You need to create a provisioning profile to deploy it to a real device.
Follow instructions here.
Hope this helps,
Liam
I am running selenium test cases in a ubuntu server which basically runs testcases in both firefox and chrome.
Firefox launches and test cases run successfully but chrome throws exception:
*****below is the snippet of the stacktrace:*****
Starting ChromeDriver (v2.8.240825) on port 21549
PAC support disabled because there is no system implementation
Test IntegrationTest.AdminUserelementscheck failed:
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.8.240825,platform=Linux 2.6.32-431.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
[error] Command duration or timeout: 20.83 seconds
Hi Below is the small snippet of my code :
public class IntegrationTest {
private static final String configFile="test.properties";
private final String FIREFOX="firefox";
private final String CHROME="chrome";
private final String PHANTOMJS="phantomjs";
private final String BROWSERNAME="browser";
private static Properties props = new Properties();
public WebDriver webDriver;
private static Configuration additionalConfigurations;
#BeforeClass
public static void setUp() throws IOException, SQLException{
props.load(IntegrationTest.class.getResourceAsStream("/" + configFile));
}
#test
public void AdminUserelementscheck() throws SQLException, IOException {
String[] browsers = props.getProperty(BROWSERNAME).split(",");
System.out.println("Number of browsers specified in conf:"+props.getProperty(BROWSERNAME));
for(String browser:browsers){
System.out.println("Browser currently processing:"+browser);
if(browser.equalsIgnoreCase(FIREFOX))
webDriver = new FirefoxDriver();
else if(browser.equalsIgnoreCase(CHROME))
webDriver = new ChromeDriver();
else
webDriver = new PhantomJSDriver();
running(testServer(3333,fakeApplication()),webDriver, new Callback<TestBrowser>() {
********* LOGIN AND ASSERTION STATMENTS*******************
browser.quit()
}
});
}
This would be because Chrome is also making use of unix containers in order to run. If you want this to run within docker, pass the docker run command
--privileged
Otherwise you can start Chrome with
--no-sandbox
I have encoutered similar problem. I am running my Selenium tests locally and "webdriver exception chrome not reachable" error suddenly showed up.
The problem was that I already had too much tabs in my regular chrome browser. After getting frustrated I have closed few tabs and suddenly it worked. I am not sure if there is a certain limit of tabs, but if somebody encounters same problem, give it a try.
Your chrome driver seems to be old. Try downloading latest as of date from below and report back if you get any new errors.
http://chromedriver.storage.googleapis.com/index.html?path=2.14/
Also ensure that PATH environment variable has the path to chromedriver.