Skip to content

Instantly share code, notes, and snippets.

View titusfortner's full-sized avatar

Titus Fortner titusfortner

View GitHub Profile
@titusfortner
titusfortner / BuildSeleniumOnWindows.md
Created July 18, 2023 21:51 — forked from sbabcoc/BuildSeleniumOnWindows.md
Building Selenium on Windows 10

Guide #1: http://jimevansmusic.blogspot.com/2020/04/setting-up-windows-development.html
Guide #2: https://gist.github.com/titusfortner/aec103e9b02709f771497fdb8b21154c

Set Up Command Line Environment

  • Launch Powershell as Administrator
  • Enable Developer Mode : reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
  • Enable UNC Path support: reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor" /t REG_DWORD /f /v "DisableUNCCheck" /d "1"
  • Install Microsoft Visual Studio 2022 Community Edition:
  • Download Visual Studio Professional 17.5.1 from https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history
package com.saucedemo.selenium;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.extension.TestWatcher;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
SAFARIDRIVER(1) BSD General Commands Manual SAFARIDRIVER(1)
NAME
safaridriver -- Safari WebDriver REST API service
SYNOPSIS
safaridriver -p port [-h | --help] [--version] [--enable] [--diagnose]
DESCRIPTION
The safaridriver utility is used to launch an HTTP server that implements the Selenium WebDriver
@titusfortner
titusfortner / pageFactoryOptimizationNoReflection.java
Last active March 19, 2023 17:03
Better way to Cache Page Factory Elements
private static final Duration MAX_WAIT = Duration.ofSeconds(10);
public void click(WebElement pageFactoryElement) {
click(pageFactoryElement, System.currentTimeMillis());
}
public void sendKeys(WebElement pageFactoryElement, String text) {
sendKeys(pageFactoryElement, text, System.currentTimeMillis());
}
@titusfortner
titusfortner / keep_alive.rb
Last active December 15, 2022 18:14
Use Keep Alive in Selenium Ruby
module Selenium
module WebDriver
module Remote
module Http
class KeepAlive < Default
def close
super
@http.finish if @http&.started?
end
@titusfortner
titusfortner / annotations.java
Last active March 20, 2020 16:00
Defining Elements in Page Objects
@TagName("form")
private Element form;
@Id("user_email") @Scope("form")
private TextField email;
@Id("user_password")
private TextField password;
@titusfortner
titusfortner / examples.rb
Created November 27, 2018 16:45
Capybara vs Watir Element Location examples
# Capybara
find('.inventory_item:first-child').click_button('ADD TO CART')
click_button('ADD TO CART', match: :first)
click_button(class: 'add-to-cart-button', match: :first)
first(:button, 'ADD TO CART').click
first(:button, class: ['add-to-cart-button']).click
first('.add-to-cart-button').click
# encoding: utf-8
#
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
@titusfortner
titusfortner / abstracted.rb
Created November 29, 2012 18:51
Abstracted Webdriver Example
include UtilityModule
initialize_test
go_to "http://google.com"
search_term = "Cheese!"
submit_text({:name => "q"}, search_term)
wait_for_element_present(:id => "search")
raise unless get_title.include?(search_term.downcase)
end_test
@titusfortner
titusfortner / page_object.rb
Created November 29, 2012 18:52
Page Object Webdriver Example
class GoogleHome
def initialize driver
@driver = driver
end
def goto
go_to "http://google.com"
return self
end
def search_field