Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. <?php
  2. /*
  3. LambdaTest selenium automation sample example
  4. Configuration
  5. ----------
  6. username: Username can be found at automation dashboard
  7. accessToken: AccessToken can be generated from automation dashboard or profile section
  8.  
  9. Result
  10. -------
  11. Execute PHP Automation Tests on LambdaTest Distributed Selenium Grid
  12. */
  13.  
  14. require 'vendor\autoload.php';
  15.  
  16. class LambdaTest{
  17.  
  18. /*
  19. Setup remote driver
  20. Params
  21. ----------
  22. platform : Supported platform - (Windows 10, Windows 8.1, Windows 8, Windows 7, macOS High Sierra, macOS Sierra, OS X El Capitan, OS X Yosemite, OS X Mavericks)
  23. browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge, Safari)
  24. version : Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/
  25. */
  26. protected static $driver;
  27.  
  28. public function searchTextOnGoogle() {
  29. # username: Username can be found at automation dashboard
  30. $LT_USERNAME = "devin.koorneweerd";
  31.  
  32. # accessKey: AccessKey can be generated from automation dashboard or profile section
  33. $LT_APPKEY = "QHEc5RuRiivXZch9JCGZ5dm8eW9vaVppHxO7uurXqrdYVcPBzX";
  34.  
  35. $LT_BROWSER = "Chrome";
  36. $LT_BROWSER_VERSION ="78.0";
  37. $LT_PLATFORM = "Windows 10";
  38.  
  39. # URL: https://{username}:{accessToken}@hub.lambdatest.com/wd/hub
  40. $url = "https://". $LT_USERNAME .":" . $LT_APPKEY ."@hub.lambdatest.com/wd/hub";
  41.  
  42. # setting desired capabilities for the test
  43. $desired_capabilities = new DesiredCapabilities();
  44. $desired_capabilities->setCapability('browserName',$LT_BROWSER);
  45. $desired_capabilities->setCapability('version', $LT_BROWSER_VERSION);
  46. $desired_capabilities->setCapability('platform', $LT_PLATFORM);
  47. $desired_capabilities->setCapability('name', "Php");
  48. $desired_capabilities->setCapability('build', "Php Build");
  49. $desired_capabilities->setCapability('network', true);
  50. $desired_capabilities->setCapability('visual', true);
  51. $desired_capabilities->setCapability('video ', true);
  52. $desired_capabilities->setCapability('console', true);
  53.  
  54. /*
  55. Setup remote drive
  56. Params
  57. ----------
  58. Execute test: navigate google.com search LambdaTest
  59. Result
  60. -------
  61. print title
  62. */
  63. self::$driver = RemoteWebDriver::create($url, $desired_capabilities);
  64.  
  65.  
  66. self::$driver->get("https://www.google.com/");
  67.  
  68. $element = self::$driver->findElement(WebDriverBy::name("q"));
  69. if($element) {
  70. $element->sendKeys("LambdaTest");
  71. $element->submit();
  72. }
  73.  
  74. print self::$driver->getTitle();
  75. self::$driver->quit();
  76. }
  77. }
  78.  
  79. $lambdaTest = new LambdaTest();
  80. $lambdaTest->searchTextOnGoogle();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement