#!/usr/bin/env rubyrequire'rubygems'require'selenium-webdriver'caps={:browserName=>"%browserName%",:version=>"%version%",:platform=>"%platform%",:deviceName=>"%deviceName%",:platformName=>"%platformName%",:name=>"My First Mobile Test"}client=Selenium::WebDriver::Remote::Http::Default.newclient.timeout=480driver=Selenium::WebDriver.for(:remote,:url=>"https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",:http_client=>client,:desired_capabilities=>caps)driver.navigate.to"https://www.google.com"element=driver.find_element(:name,'q')element.send_keys"TestingBot"element.submitputsdriver.titledriver.quit
#!/usr/bin/env rubyrequire'rubygems'require'selenium-webdriver'caps={:browserName=>"%browserName%",:version=>"%version%",:platform=>"%platform%",:deviceName=>"%deviceName%",:platformName=>"%platformName%",:realDevice=>true,:name=>"My First Mobile Test"}client=Selenium::WebDriver::Remote::Http::Default.newclient.timeout=480driver=Selenium::WebDriver.for(:remote,:url=>"https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",:http_client=>client,:desired_capabilities=>caps)driver.navigate.to"https://www.google.com"element=driver.find_element(:name,'q')element.send_keys"TestingBot"element.submitputsdriver.titledriver.quit
<?phprequire_once('vendor/autoload.php');useFacebook\WebDriver\Remote\RemoteWebDriver;useFacebook\WebDriver\WebDriverBy;$capabilities=array('browserName'=>"%browserName%",'version'=>"%version%",'platform'=>"%platform%",'deviceName'=>"%deviceName%",'platformName'=>"%platformName%",'name'=>"My First Mobile Test");$web_driver=RemoteWebDriver::create("https://api_key:api_secret@hub.testingbot.com/wd/hub",$capabilities,240000);$web_driver->get("https://google.com");$element=$web_driver->findElement(WebDriverBy::name("q"));if($element){$element->sendKeys("TestingBot");$element->submit();}print$web_driver->getTitle();$web_driver->quit();?>
<?phprequire_once('vendor/autoload.php');useFacebook\WebDriver\Remote\RemoteWebDriver;useFacebook\WebDriver\WebDriverBy;$capabilities=array('browserName'=>"%browserName%",'version'=>"%version%",'platform'=>"%platform%",'deviceName'=>"%deviceName%",'platformName'=>"%platformName%",'realDevice'=>true,'name'=>"My First Mobile Test");$web_driver=RemoteWebDriver::create("https://api_key:api_secret@hub.testingbot.com/wd/hub",$capabilities,240000);$web_driver->get("https://google.com");$element=$web_driver->findElement(WebDriverBy::name("q"));if($element){$element->sendKeys("TestingBot");$element->submit();}print$web_driver->getTitle();$web_driver->quit();?>
importorg.openqa.selenium.By;importorg.openqa.selenium.Platform;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.WebElement;importorg.openqa.selenium.remote.DesiredCapabilities;importorg.openqa.selenium.remote.RemoteWebDriver;importjava.net.URL;publicclassJavaSample{publicstaticfinalStringKEY="KEY";publicstaticfinalStringSECRET="SECRET";publicstaticfinalStringURL="https://"+KEY+":"+SECRET+"@hub.testingbot.com/wd/hub";publicstaticvoidmain(String[]args)throwsException{DesiredCapabilitiescaps=newDesiredCapabilities();caps.setCapability("browserName","%browserName%");caps.setCapability("version","%version%");caps.setCapability("platform","%platform%");caps.setCapability("deviceName","%deviceName%");caps.setCapability("platformName","%platformName%");caps.setCapability("name","My First Mobile Test");WebDriverdriver=newRemoteWebDriver(newURL(URL),caps);driver.get("https://www.google.com/ncr");WebElementelement=driver.findElement(By.name("q"));element.sendKeys("TestingBot");element.submit();System.out.println(driver.getTitle());driver.quit();}}
importorg.openqa.selenium.By;importorg.openqa.selenium.Platform;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.WebElement;importorg.openqa.selenium.remote.DesiredCapabilities;importorg.openqa.selenium.remote.RemoteWebDriver;importjava.net.URL;publicclassJavaSample{publicstaticfinalStringKEY="KEY";publicstaticfinalStringSECRET="SECRET";publicstaticfinalStringURL="https://"+KEY+":"+SECRET+"@hub.testingbot.com/wd/hub";publicstaticvoidmain(String[]args)throwsException{DesiredCapabilitiescaps=newDesiredCapabilities();caps.setCapability("browserName","%browserName%");caps.setCapability("version","%version%");caps.setCapability("platform","%platform%");caps.setCapability("realDevice",true);caps.setCapability("deviceName","%deviceName%");caps.setCapability("platformName","%platformName%");caps.setCapability("name","My First Mobile Test");WebDriverdriver=newRemoteWebDriver(newURL(URL),caps);driver.get("https://www.google.com/ncr");WebElementelement=driver.findElement(By.name("q"));element.sendKeys("TestingBot");element.submit();System.out.println(driver.getTitle());driver.quit();}}
importunittestimportsysfromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.common.desired_capabilitiesimportDesiredCapabilitiesfromtestingbotclientimportTestingBotClientclassTestTestingBotClient(unittest.TestCase):defsetUp(self):desired_cap={'browserName':'%browserName%','version':'%version%','platform':'%platform%','deviceName':'%deviceName%','platformName':'%platformName%','name':'My First Mobile Test',}self.driver=webdriver.Remote(command_executor='http://key:secret@hub.testingbot.com/wd/hub',desired_capabilities=desired_cap)deftest_google_example(self):self.driver.get("https://www.google.com")ifnot"Google"inself.driver.title:raiseException("Unable to load google page!")elem=self.driver.find_element_by_name("q")elem.send_keys("TestingBot")elem.submit()deftearDown(self):self.driver.quit()status=sys.exc_info()==(None,None,None)tb_client=TestingBotClient('key','secret')tb_client.tests.update_test(self.driver.session_id,self._testMethodName,status)if__name__=='__main__':unittest.main()
importunittestimportsysfromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.common.desired_capabilitiesimportDesiredCapabilitiesfromtestingbotclientimportTestingBotClientclassTestTestingBotClient(unittest.TestCase):defsetUp(self):desired_cap={'browserName':'%browserName%','version':'%version%','platform':'%platform%','deviceName':'%deviceName%','realDevice':true,'platformName':'%platformName%','name':'My First Mobile Test',}self.driver=webdriver.Remote(command_executor='http://key:secret@hub.testingbot.com/wd/hub',desired_capabilities=desired_cap)deftest_google_example(self):self.driver.get("https://www.google.com")ifnot"Google"inself.driver.title:raiseException("Unable to load google page!")elem=self.driver.find_element_by_name("q")elem.send_keys("TestingBot")elem.submit()deftearDown(self):self.driver.quit()status=sys.exc_info()==(None,None,None)tb_client=TestingBotClient('key','secret')tb_client.tests.update_test(self.driver.session_id,self._testMethodName,status)if__name__=='__main__':unittest.main()
constwd=require('wd'),testingbotKey="api_key",testingbotSecret="api_secret"desiredCaps={'browserName':'%browserName%','version':'%version%','platform':'%platform%','deviceName':'%deviceName%','platformName':'%platformName%','name':'My First Mobile Test'}driver=wd.remote("https://"+testingbotKey+":"+testingbotSecret+"@"+"hub.testingbot.com/wd/hub")driver.init(desiredCaps,function(){driver.get('https://www.google.com',function(){driver.title(function(err,title){console.log(title)driver.quit()})})})
constwd=require('wd'),testingbotKey="api_key",testingbotSecret="api_secret"desiredCaps={'browserName':'%browserName%','version':'%version%','platform':'%platform%','deviceName':'%deviceName%','platformName':'%platformName%','realDevice':true,'name':'My First Mobile Test'}driver=wd.remote("https://"+testingbotKey+":"+testingbotSecret+"@"+"hub.testingbot.com/wd/hub")driver.init(desiredCaps,function(){driver.get('https://www.google.com',function(){driver.title(function(err,title){console.log(title)driver.quit()})})})
Portrait/Landscape
It's possible to rotate the device before and during your test. Please see these examples:
Rotate before test (iOS only):
desired_capabilities ={"orientation" : "LANDSCAPE "}# or PORTRAIT
driver=awaitnewwebdriver.Builder().withCapabilities({"browserName":'safari',"platformName":'iOS',"deviceName":'iPhone 15',"browserVersion":'17.4',/** Google requires "w3c" to be set in "goog:chromeOptions" as true if you're using ChromeDriver version 74 or lower.
* Based on this commit: https://chromium.googlesource.com/chromium/src/+/2b49880e2481658e0702fd6fe494859bca52b39c
* ChromeDriver now uses w3c by default from version 75+ so setting this option will no longer be a requirement **/"goog:chromeOptions":{"w3c":true},"tb:options":{"key":"api_key","secret":"api_secret","appiumVersion":"2.4.1"}}).usingServer("https://hub.testingbot.com/wd/hub").build();