Skip to content

Latest commit

 

History

History
135 lines (87 loc) · 3.39 KB

README.md

File metadata and controls

135 lines (87 loc) · 3.39 KB

ObjWebDriver

Reimplemented version of Selenium.framework for compatibility with ObjFW.

Features

Usage

RemoteWebDriver (aka SeleniumServer)

#import <ObjFW/ObjFW.h>
#import <Selenium/Selenium.h>

@interface AppDelegate: OFObject<OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(AppDelegate)

@implementation AppDelegate

- (void)applicationDidFinishLaunching
{
	SECapabilities *c = [SECapabilities new];
 	c.browserName = @"firefox";

 	SERemoteWebDriver *driver = [[SERemoteWebDriver alloc] initWithServerAddress:@"localhost" port:4444 desiredCapabilities:c requiredCapabilities:nil error:NULL];

 	driver.url = [OFURL URLWithString:@"https://google.com"];

 	[driver quit];

 	[OFApplication terminate];
}
@end

GeckoDriver (FireFox browser)

#import <ObjFW/ObjFW.h>
#import <Selenium/Selenium.h>

@interface AppDelegate: OFObject<OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(AppDelegate)

@implementation AppDelegate

- (void)applicationDidFinishLaunching
{
	SERemoteWebDriver *driver = [[SEGeckoDriver alloc] initWithExecutable:@"/usr/local/bin/geckodriver"];

 	SECapabilities *c = [SECapabilities new];

  	[driver startSessionWithDesiredCapabilities:c requiredCapabilities:nil];

  	driver.url = [OFURL URLWithString:@"https://google.com"];

  	[driver quit];

  	[OFApplication terminate];
}
@end

GeckoDriver (already executed webdriver server usage)

#import <ObjFW/ObjFW.h>
#import <Selenium/Selenium.h>

@interface AppDelegate: OFObject<OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(AppDelegate)

@implementation AppDelegate

- (void)applicationDidFinishLaunching
{
	SERemoteWebDriver *driver = [[SEGeckoDriver alloc] initWithServerAddress:@"localhost" port:4444];

 	SECapabilities *c = [SECapabilities new];

  	[driver startSessionWithDesiredCapabilities:c requiredCapabilities:nil];

  	driver.url = [OFURL URLWithString:@"https://google.com"];

  	[driver quit];

  	[OFApplication terminate];
}
@end
OR
#import <ObjFW/ObjFW.h>
#import <Selenium/Selenium.h>

@interface AppDelegate: OFObject<OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(AppDelegate)

@implementation AppDelegate

- (void)applicationDidFinishLaunching
{
	SECapabilities *c = [SECapabilities new];

 	SERemoteWebDriver *driver = [[SEGeckoDriver alloc] initWithServerAddress:@"localhost" port:4444 desiredCapabilities:c requiredCapabilities:nil error:NULL];

 	driver.url = [OFURL URLWithString:@"https://google.com"];

 	[driver quit];

 	[OFApplication terminate];
}
@end

For more information and examples look at Appium.app or source.

Requirements

  • Clang 3.8+
  • ObjFW v0.9-dev+

How to build

objfw-compile --arc -I/path/to/repo -I/path/to/repo/Selenium main.m /path/to/repo/.m /path/to/repo/Selenium/.m -o myapp