Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
shopify-codeception
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
Predators
Shopify
Libraries
shopify-codeception
Compare revisions
732dbc599e1d2769d3ac1105e43117f4767b1172 to f3b550b1b5f71711bfd1542a35d5ec651f865cae
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
wpdesk/predators/shopify/libraries/shopify-codeception
Select target project
No results found
f3b550b1b5f71711bfd1542a35d5ec651f865cae
Select Git revision
Branches
main
Tags
1.0.0
1.0.0-beta1
1.0.0-beta2
1.0.0-beta3
1.0.0-beta4
1.0.0-beta6
1.0.0-beta7
1.0.1
1.0.2
10 results
Swap
Target
wpdesk/predators/shopify/libraries/shopify-codeception
Select target project
wpdesk/predators/shopify/libraries/shopify-codeception
1 result
732dbc599e1d2769d3ac1105e43117f4767b1172
Select Git revision
Branches
main
Tags
1.0.0
1.0.0-beta1
1.0.0-beta2
1.0.0-beta3
1.0.0-beta4
1.0.0-beta6
1.0.0-beta7
1.0.1
1.0.2
10 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
feature(account): choose
· f3e27404
Grzegorz Rola
authored
1 year ago
f3e27404
Merge branch 'feature/login' into 'main'
· f3b550b1
Grzegorz Rola
authored
1 year ago
feature(account): choose See merge request
!2
f3b550b1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+4
-0
4 additions, 0 deletions
CHANGELOG.md
src/Shopify.php
+74
-36
74 additions, 36 deletions
src/Shopify.php
with
78 additions
and
36 deletions
CHANGELOG.md
View file @
f3b550b1
## [1.0.1] - 2023-08-17
### Fixed
-
account choose
## [1.0.0] - 2023-08-17
### Added
-
initial version
This diff is collapsed.
Click to expand it.
src/Shopify.php
View file @
f3b550b1
...
...
@@ -12,20 +12,67 @@ class Shopify extends WebDriver
public
function
loginAsAdmin
():
void
{
$i
=
$this
;
$isPl
=
false
;
if
(
$i
->
loadSessionSnapshot
(
'admin'
))
{
return
;
}
$i
->
amOnUrl
(
$this
->
config
[
'admin_url'
]);
try
{
$i
->
moveMouseOver
(
'body'
,
rand
(
1
,
100
),
rand
(
1
,
100
));
$i
->
seeInCurrentUrl
(
parse_url
(
$this
->
config
[
'admin_url'
],
PHP_URL_PATH
));
$this
->
amLoggedInAsAdmin
(
$i
);
}
catch
(
Exception
$e
)
{
try
{
$i
->
wait
(
rand
(
1
,
2
));
$i
->
see
(
'Choose an account'
);
$i
->
click
(
$this
->
config
[
'admin_username'
]);
}
catch
(
Exception
$e
)
{
$this
->
loginWithGoogle
(
$i
);
}
}
$i
->
wait
(
rand
(
1
,
5
));
$i
->
saveSessionSnapshot
(
'admin'
);
}
public
function
amOnPage
(
$page
):
void
{
parent
::
amOnPage
(
$page
);
$this
->
loginOnFront
();
}
public
function
loginOnFront
():
void
{
$i
=
$this
;
try
{
$i
->
seeInCurrentUrl
(
'password'
);
$i
->
fillField
(
'password'
,
$this
->
config
[
'store_password'
]);
$i
->
click
(
'button[type=submit]'
);
}
catch
(
Exception
$e
)
{
// do nothing
}
}
/**
* @param Shopify $i
*
* @return void
*/
private
function
amLoggedInAsAdmin
(
Shopify
$i
):
void
{
$i
->
moveMouseOver
(
'body'
,
rand
(
1
,
100
),
rand
(
1
,
100
));
$i
->
seeInCurrentUrl
(
parse_url
(
$this
->
config
[
'admin_url'
],
PHP_URL_PATH
));
}
/**
* @param Shopify $i
*
* @return void
* @throws Exception
*/
private
function
loginWithGoogle
(
Shopify
$i
):
void
{
$isPl
=
false
;
try
{
$i
->
waitForText
(
'Continue with Google'
,
10
);
$i
->
waitForText
(
'Continue with Google'
,
5
);
}
catch
(
Exception
$e
)
{
$i
->
waitForText
(
'Kontynuuj z Google'
,
30
);
$i
->
waitForText
(
'Kontynuuj z Google'
,
5
);
$isPl
=
true
;
}
$i
->
click
(
$isPl
?
'Kontynuuj z Google'
:
'Continue with Google'
);
...
...
@@ -35,10 +82,24 @@ class Shopify extends WebDriver
}
catch
(
Exception
$e
)
{
try
{
$i
->
waitForText
(
$this
->
config
[
'admin_username'
]);
$i
->
clickWithLeftButton
(
Locator
::
find
(
'div'
,
[
'data-email'
=>
$this
->
config
[
'admin_username'
]]));
$i
->
clickWithLeftButton
(
Locator
::
find
(
'div'
,
[
'data-email'
=>
$this
->
config
[
'admin_username'
]]));
$i
->
seeInCurrentUrl
(
parse_url
(
$this
->
config
[
'admin_url'
],
PHP_URL_PATH
));
$i
->
dontSeeInCurrentUrl
(
'google.com'
);
}
catch
(
Exception
$e
)
{
$this
->
loginToGoogle
(
$i
,
$isPl
);
}
}
}
/**
* @param Shopify $i
* @param bool $isPl
*
* @return void
*/
private
function
loginToGoogle
(
Shopify
$i
,
bool
$isPl
):
void
{
$i
->
wait
(
rand
(
1
,
5
));
$i
->
moveMouseOver
(
'body'
,
rand
(
1
,
100
),
rand
(
1
,
100
));
try
{
...
...
@@ -56,28 +117,5 @@ class Shopify extends WebDriver
$i
->
click
(
$isPl
?
'Dalej'
:
'Next'
);
}
}
}
}
$i
->
wait
(
rand
(
1
,
5
));
$i
->
saveSessionSnapshot
(
'admin'
);
}
public
function
amOnPage
(
$page
):
void
{
parent
::
amOnPage
(
$page
);
$this
->
loginOnFront
();
}
public
function
loginOnFront
():
void
{
$i
=
$this
;
try
{
$i
->
seeInCurrentUrl
(
'password'
);
$i
->
fillField
(
'password'
,
$this
->
config
[
'store_password'
]);
$i
->
click
(
'button[type=submit]'
);
}
catch
(
Exception
$e
)
{
// do nothing
}
}
}
This diff is collapsed.
Click to expand it.