-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitHubLoginSmokeTest.php
More file actions
63 lines (52 loc) · 2.18 KB
/
Copy pathGitHubLoginSmokeTest.php
File metadata and controls
63 lines (52 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\WebDriverBy;
use PHPUnit\Framework\TestCase;
class GitHubLoginSmokeTest extends TestCase
{
private $driver;
protected function setUp(): void
{
// Use absolute path without environment variable
$options = new ChromeOptions();
$options->addArguments([
'--no-sandbox',
'--disable-dev-shm-usage'
]);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
// Connect to running ChromeDriver instance
$this->driver = RemoteWebDriver::create(
'http://localhost:9515',
$capabilities
);
}
public function testGitHubLoginForm()
{
// Navigate to GitHub login page
$this->driver->get('https://github.com/login');
// Test username field
$loginField = $this->driver->findElement(WebDriverBy::id('login_field'));
$this->assertTrue($loginField->isDisplayed());
$this->assertEquals('login_field', $loginField->getAttribute('id'));
// Test password field
$passwordField = $this->driver->findElement(WebDriverBy::id('password'));
$this->assertTrue($passwordField->isDisplayed());
$this->assertEquals('password', $passwordField->getAttribute('type'));
// Test sign-in button
$signInButton = $this->driver->findElement(WebDriverBy::cssSelector('input[type="submit"]'));
$this->assertTrue($signInButton->isDisplayed());
$this->assertEquals('Sign in', $signInButton->getAttribute('value'));
// Test forgot password link
$forgotPasswordLink = $this->driver->findElement(WebDriverBy::linkText('Forgot password?'));
$this->assertTrue($forgotPasswordLink->isDisplayed());
// Test page title
$this->assertEquals('Sign in to GitHub · GitHub', $this->driver->getTitle());
}
protected function tearDown(): void
{
$this->driver->quit();
}
}