Skip to content

Instantly share code, notes, and snippets.

@zevnull
zevnull / [Mac OS] completely uninstall node + npm
Created November 11, 2014 12:17
[Mac OS] completely uninstall node + npm
To completely uninstall node + npm is to do the following:
go to /usr/local/lib and delete any node and node_modules
go to /usr/local/include and delete any node and node_modules directory
if you installed with brew install node, then run brew uninstall node in your terminal
check your Home directory for any "local" or "lib" or "include" folders, and delete any "node" or "node_modules" from there
go to /usr/local/bin and delete any node executable
You may need to do the additional instructions as well:
remove: /usr/local/bin/npm
@zevnull
zevnull / disable all jenkins jobs
Created September 18, 2014 14:37
disable all jenkins jobs
import hudson.model.*
for(item in Hudson.instance.items) {
println("JOB : "+item.name)
item.disabled=true
item.save()
println("\n=======\n")
}
HashMap<String, String> scrollObject = new HashMap<String, String>();
//Must be an element with scrollable property; Android (ListView,ScrollabeView) IOS (UIAScrollableView
RemoteWebElement element = (RemoteWebElement) driver.findElement(By.[id/name/etc](scrollableElement));
JavascriptExecutor js = (JavascriptExecutor) driver;
String widId = ((RemoteWebElement) element).getId();
//Text for search on the screen
scrollObject.put("text", text);
scrollObject.put("element", widId);
js.executeScript("mobile: scrollTo", scrollObject);
So you'd like to manage your iOS devices by command line?
You can use libimobiledevice tools for that.
Easy on Linux. Let's see how it is on Mac OS X.
You'll need to:
1. install Xcode
2. start Xcode and agree to it's license
3. install Xcode command line tools (Start Xcode, Go to Preferences -> Downloads tab)
4. install homebrew by this command (sudo password will be prompted)
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
@zevnull
zevnull / SwipeTest.java
Created October 16, 2013 07:15
capture screens
// how to capture screens?
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String filename = "c:\\screenshot098765.png";
FileUtils.copyFile(screenshot, new File(filename));
@zevnull
zevnull / SwipeTest.java
Created October 15, 2013 14:14
Get element ID for appium swipe
WebElement end = driver.findElements(By.className("android.widget.TextView")).get(10);
((RemoteWebElement)end).getId();
@zevnull
zevnull / SeleniumExamples.java
Last active December 24, 2015 13:59
Selenium. Manual drag and drop
// Selenium
// Manual Drag And Drop
Action dragAndDrop = new Actions(driver)
.clickAndHold(element1)
.moveToElement(element2)
.release()
.build();
dragAndDrop.perform();
@zevnull
zevnull / gist:6634682
Created September 20, 2013 08:23
take screenshot using Remote webdriver
public class ScreenShotRemoteWebDriver extends RemoteWebDriver implements TakesScreenshot {
public ScreenShotRemoteWebDriver(URL url, DesiredCapabilities capabilities) {
super(url, capabilities);
}
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
if ((Boolean)getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT)) {
return target.convertFromBase64Png(execute(DriverCommand.SCREENSHOT).getValue().to­String());
}
return null;
}}
switch( deviceType )
{
case HEADNODE:
return true;
case STORAGE:
for( String metric : metricsList )
{
if( metric.contains( METRIC_KEY_STORAGE ) )
specificMetricCount++;
@zevnull
zevnull / UserIDElement.java
Created May 24, 2013 10:35
Element screenshot
BrowserFactory.getExistentWebDriver().switchTo().frame( "outerFrame" );
WebElement ele =
BrowserFactory.getExistentWebDriver().findElement( By.cssSelector( "canvas.flot-overlay" ) );
File screenshot = ( ( TakesScreenshot ) BrowserFactory.getExistentWebDriver() ).getScreenshotAs( OutputType.FILE );
BufferedImage fullImg = ImageIO.read( screenshot );
Point point = ele.getLocation();
int eleWidth = ele.getSize().getWidth();
int eleHeight = ele.getSize().getHeight();