diff --git a/.gitignore b/.gitignore index aaa10c1..8f45964 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,168 @@ + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +### Eclipse +.settings/ +.classpath +.project + + +# Created by https://www.gitignore.io/api/macos,java,windows,intellij,intellij+iml,maven + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml + +# Sensitive or high-churn files: +.idea/dataSources/ +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + + +### Intellij+iml ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: + +# Sensitive or high-churn files: + +# Gradle: + +# Mongo Explorer plugin: + +## File-based project format: + +## Plugin-specific files: + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +### Intellij+iml Patch ### +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Exclude maven wrapper +!/.mvn/wrapper/maven-wrapper.jar + + +### Java ### *.class +# BlueJ files +*.ctxt + # Mobile Tools for Java (J2ME) .mtj.tmp/ @@ -10,17 +173,3 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* - -### IntelliJ Idea -#.idea/ -*.iml -*.ipr -*.iws - -### Eclipse -.settings/ -.classpath -.project - -### Maven -target/ \ No newline at end of file diff --git a/README.md b/README.md index c9b9f71..4da1a23 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,23 @@ Run these commands depending on your base OS. ### On Mac OS +Copy this bootstrap script and run it in a Terminal shell window: + + ``` + sh -c "$(curl -fsSL https://raw.githubusercontent.com/wilsonmar/Basic-Selenium-Java/master/mac-bootstrap.sh)" + ``` + +It installs the following if it is not already installed: + 1. Install Homebrew `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` 2. Install Caskroom `brew tap caskroom/cask` 3. If you dont have the Java Development Kit (JDK) run this command `brew cask install java` 4. Install Maven `brew install maven` 5. Run `./mac_install_browsers.sh` -### Windows +The script also runs the test. + +### On Windows > This is currently untested @@ -38,9 +48,11 @@ The following commands are instructions on how to run the tests ### From CLI -`mvn test -Dsurefire.suiteXmlFiles=mac-only.xml ` on a mac +On a Mac: + + `mvn test -Dsurefire.suiteXmlFiles=mac-only.xml` -### Intellij Idea +### Intellij IDEA There is a shared run configuration that has the maven target setup and another with a sample built in NUnit test runner option. diff --git a/mac-bootstrap.sh b/mac-bootstrap.sh new file mode 100755 index 0000000..0ce6a63 --- /dev/null +++ b/mac-bootstrap.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +# mac-bootstrap.sh +# by wilsonmar at gmail.com +# This bash script bootstraps a MacOS laptop (like at https://github.com/fs/osx-bootstrap) +# to run Selenium against a Java source file that +# simply opens a web page in several browsers. +# +# This script installs: +# - xcode +# - homebrew +# +# It will ask you for your sudo password. + +fancy_echo() { # to add blank line between echo statements: + local fmt="$1"; shift + # shellcheck disable=SC2059 + printf "\n$fmt\n" "$@" +} + +fancy_echo "Boostrapping ..." + +trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT + +set -e # to stop on error. + +# Ask for the administrator password upfront and run a +# keep-alive to update existing `sudo` time stamp until script has finished +# sudo -v +# while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & + +# Ensure Apple's command line tools are installed +if ! command -v cc >/dev/null; then + fancy_echo "Installing xcode (Agreeing to the Xcode/iOS license requires sudo admin privileges) ..." + sudo xcodebuild -license accept + # xcode-select --install +else + fancy_echo "Xcode already installed. Skipping." +fi + + +if ! command -v brew >/dev/null; then + fancy_echo "Installing Homebrew..." + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" /dev/null; then + fancy_echo "Installing Java..." + brew cask install java +else + fancy_echo "Java already installed. Skipping." +fi + + +if ! command -v mvn >/dev/null; then + fancy_echo "Installing Maven..." + brew install maven +else + fancy_echo "Maven already installed. Skipping." +fi + + +fancy_echo "Run mac_install_browsers.sh ..." +chmod +x mac_install_browsers.sh +./mac_install_browsers.sh + + +fancy_echo "Run test ..." +mvn test -Dsurefire.suiteXmlFiles=mac-only.xml +# Browser windows should open and close on their own. + +fancy_echo "Done with status $? (0=OK)."