1 package okw.gui.frames;
3 import okw.gui.adapter.selenium.SeBrowserWindow;
6 import javax.xml.xpath.XPathExpressionException;
9 import org.openqa.selenium.firefox.FirefoxBinary;
10 import org.openqa.selenium.firefox.FirefoxDriver;
11 import org.openqa.selenium.firefox.FirefoxOptions;
14 import okw.OKW_Memorize_Sngltn;
32 public void SelectWindow()
47 LogFunctionStartDebug(
"StartApp" );
52 String OKWGeckodriverPath;
54 if ( ( OKWGeckodriverPath = System.getProperty(
"webdriver.gecko.driver" ) ) !=
null )
56 LogPrint(
"System.Property: webdriver.gecko.driver is set: '" + OKWGeckodriverPath +
"'" );
57 MEM.
set(
"System.Property: webdriver.gecko.driver", OKWGeckodriverPath );
59 else if ( ( OKWGeckodriverPath = System.getenv(
"OKWGeckodriverPath" ) ) !=
null )
61 LogPrint(
"System.Property: webdriver.gecko.driver is not set" );
62 LogPrint(
"EnvVar: OKWGeckodriverPath='" + OKWGeckodriverPath +
"'" );
63 System.setProperty(
"webdriver.gecko.driver", OKWGeckodriverPath );
65 MEM.
set(
"System.Property: webdriver.gecko.driver", OKWGeckodriverPath );
66 MEM.
set(
"OKW EnvVar: OKWGeckodriverPath", OKWGeckodriverPath );
70 LogPrint(
"System.Property: webdriver.gecko.driver is not set" );
71 LogWarning(
"Enviroment Variable 'OKWGeckodriverPath' is not set!" );
73 String os_name = System.getProperty(
"os.name" );
78 System.setProperty(
"webdriver.gecko.driver",
"/Applications/geckodriver" );
79 MEM.
set(
"System Propety: OKWGeckodriverPath", System.getProperty(
"webdriver.gecko.driver" ) );
82 LogError(
"Unknown Property: 'os.name'= '" + System.getProperty(
"os.name" ) +
"'" );
88 FirefoxBinary firefoxBinary =
new FirefoxBinary();
91 FirefoxOptions firefoxOptions =
new FirefoxOptions();
92 firefoxOptions.setBinary(firefoxBinary);
94 mySeDriver.setDriver(
new FirefoxDriver(firefoxOptions) );
96 catch (XPathExpressionException e)
98 throw new RuntimeException( e );
102 LogFunctionEndDebug();
106 public void StopApp()
108 LogFunctionStartDebug(
"StopApp()" );
111 mySeDriver.getDriver().quit();
115 Runtime rt = Runtime.getRuntime();
117 if (System.getProperty(
"os.name").toLowerCase().indexOf(
"windows") > -1)
119 LogPrintDebug(
"before windows taskkill geckodriver " );
124 LogPrintDebug(
"before linux/osx pkill -f geckodriver" );
125 Process p = rt.exec(
"pkill -f geckodriver");
135 LogPrintDebug(
"before catch (InterruptedException | IOException e)" );
138 LogPrintDebug(
"after catch (InterruptedException | IOException e)" );
142 LogPrintDebug(
"finaly.. " );
143 LogFunctionEndDebug();