Advertisement
Guest User

Untitled

a guest
May 10th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 KB | None | 0 0
  1. import geb.Browser
  2. import org.openqa.selenium.firefox.FirefoxDriver
  3. import org.openqa.selenium.WebDriver
  4. import org.openqa.selenium.phantomjs.PhantomJSDriver
  5. import org.openqa.selenium.phantomjs.PhantomJSDriverService
  6. import org.openqa.selenium.remote.DesiredCapabilities
  7. import org.openqa.selenium.Dimension
  8.  
  9. env = System.getenv()
  10.  
  11. def username = env.username
  12. def password = env.password
  13. def gateway = env.gateway
  14.  
  15. def matcher = gateway =~ /^(https?://)([^:^/]*)(:d*)?(.*)?.*$/
  16. def host = matcher[0][2]
  17. def port = matcher[0][3]
  18.  
  19. if (env.driver == 'firefox') {
  20. driver = new FirefoxDriver()
  21. } else {
  22. println env.phantomjspath
  23. def caps = DesiredCapabilities.phantomjs()
  24. caps.setCapability(
  25. PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, env.phantomjspath
  26. )
  27. driver = new PhantomJSDriver(caps)
  28. driver.manage().window().setSize(new Dimension(1028, 768))
  29. }
  30.  
  31. def browser = new Browser(driver: driver)
  32.  
  33. BiHome = "https://" + username + ":" + password + "@" + host + port + "/gateway/default/BigInsightsWeb/#/welcome"
  34.  
  35. browser.drive {
  36.  
  37. go BiHome
  38.  
  39. // code omitted for brevity
  40. }
  41.  
  42. browser.close()
  43.  
  44. :CheckHomePhantomJS
  45. /Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/build/webdriver/phantomjs/bin/phantomjs
  46. May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
  47. INFO: executable: /Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/build/webdriver/phantomjs/bin/phantomjs
  48. May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
  49. INFO: port: 19084
  50. May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
  51. INFO: arguments: [--webdriver=19084, --webdriver-logfile=/Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/phantomjsdriver.log]
  52. May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
  53. INFO: environment: {}
  54. PhantomJS is launching GhostDriver...
  55. [INFO - 2016-05-10T09:13:58.925Z] GhostDriver - Main - running on port 19084
  56. [INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
  57. [INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - page.customHeaders: - {}
  58. [INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"mac-unknown-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
  59. [INFO - 2016-05-10T09:13:59.117Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 8784a390-168f-11e6-bcd7-a7a5f8e205b1
  60. Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: MAC
  61. Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
  62. System info: host: 'xxxxxxx', ip: 'xxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: 'xxxxx', java.version: '1.8.0_66'
  63. Driver info: driver.version: FirefoxDriver
  64. at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:75)
  65. at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
  66. at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
  67. at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
  68. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  69.  
  70. import org.apache.tools.ant.taskdefs.condition.Os
  71.  
  72. // set the dependencies for running the groovy script
  73. buildscript {
  74. repositories {
  75. mavenCentral()
  76. }
  77. dependencies {
  78. classpath 'org.codehaus.groovy:groovy-all:latest.release'
  79. }
  80. }
  81.  
  82. plugins {
  83. id 'groovy'
  84. }
  85.  
  86. apply from: "osSpecificDownloads.gradle"
  87.  
  88. // set the dependencies for compiling the groovy script
  89. repositories {
  90. mavenCentral()
  91. }
  92.  
  93. dependencies {
  94. compile 'org.codehaus.groovy:groovy-all:latest.release'
  95. compile 'org.codehaus.geb:geb-core:latest.release'
  96. compile 'org.seleniumhq.selenium:selenium-firefox-driver:2.53.0'
  97. compile('com.codeborne:phantomjsdriver:1.3.0') {
  98. transitive = false
  99. }
  100. }
  101.  
  102. // tell gradle the groovy script is in the same folder as the build.gradle file
  103. sourceSets {
  104. main {
  105. groovy {
  106. srcDirs = ['.']
  107. }
  108. }
  109. }
  110.  
  111. Properties props = new Properties()
  112. props.load(new FileInputStream("$projectDir/../../connection.properties"))
  113.  
  114. task("CheckHomePhantomJS", type: JavaExec) {
  115.  
  116. dependsOn unzipPhantomJs
  117.  
  118. def phantomJsFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "phantomjs.exe" : "bin/phantomjs"
  119.  
  120. environment 'phantomjspath', new File(unzipPhantomJs.outputs.files.singleFile, phantomJsFilename).absolutePath
  121. environment 'driver', 'phantomjs'
  122.  
  123. environment 'gateway', props.gateway
  124. environment 'username', props.username
  125. environment 'password', props.password
  126.  
  127. main = 'CheckHome'
  128. classpath = sourceSets.main.runtimeClasspath
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement