Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ChromeDevTools
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
Releases
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FrameIT
ChromeDevTools
Commits
00f37935
Commit
00f37935
authored
9 years ago
by
brewdente
Browse files
Options
Downloads
Patches
Plain Diff
Adding comments to the sample Program.cs
parent
fb541ec9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Sample/Program.cs
+27
-8
27 additions, 8 deletions
source/Sample/Program.cs
with
27 additions
and
8 deletions
source/Sample/Program.cs
+
27
−
8
View file @
00f37935
...
@@ -17,28 +17,47 @@ namespace MasterDevs.ChromeDevTools.Sample
...
@@ -17,28 +17,47 @@ namespace MasterDevs.ChromeDevTools.Sample
{
{
static
void
Main
(
string
[]
args
)
static
void
Main
(
string
[]
args
)
{
{
// STEP 1 - Run Chrome
var
chromeProcessFactory
=
new
ChromeProcessFactory
();
var
chromeProcessFactory
=
new
ChromeProcessFactory
();
using
(
var
chromeProcess
=
chromeProcessFactory
.
Create
(
9222
))
using
(
var
chromeProcess
=
chromeProcessFactory
.
Create
(
9222
))
{
{
// STEP 2 - Create a debugging session
var
endpointUrl
=
chromeProcess
.
GetSessions
().
Result
.
LastOrDefault
();
var
endpointUrl
=
chromeProcess
.
GetSessions
().
Result
.
LastOrDefault
();
var
chromeSessionFactory
=
new
ChromeSessionFactory
();
var
chromeSessionFactory
=
new
ChromeSessionFactory
();
var
chromeSession
=
chromeSessionFactory
.
Create
(
endpointUrl
);
var
chromeSession
=
chromeSessionFactory
.
Create
(
endpointUrl
);
var
pageEnableResult
=
chromeSession
.
SendAsync
<
ChromeDevTools
.
Protocol
.
Network
.
EnableCommand
>().
Result
;
chromeSession
.
Subscribe
<
ChromeDevTools
.
Protocol
.
Network
.
ResponseReceivedEvent
>((
o
,
e
)
=>
// STEP 3 - Send a command
//
// Here we are sending a command to tell chrome to navigate to
// the specified URL
var
navigateResponse
=
chromeSession
.
SendAsync
(
new
NavigateCommand
{
Url
=
"http://www.google.com"
})
.
Result
;
Console
.
WriteLine
(
"NavigateResponse: "
+
navigateResponse
.
Id
);
// STEP 4 - Register for events (in this case, "Page" domain events)
// send an event to tell chrome to send us all Page events
// but we only subscribe to certain events in this session
var
pageEnableResult
=
chromeSession
.
SendAsync
<
ChromeDevTools
.
Protocol
.
Page
.
EnableCommand
>().
Result
;
Console
.
WriteLine
(
"PageEnable: "
+
pageEnableResult
.
Id
);
chromeSession
.
Subscribe
<
Protocol
.
Page
.
DomContentEventFiredEvent
>((
o
,
e
)
=>
{
{
Console
.
WriteLine
(
"Response Received"
);
var
domContentEvent
=
(
Event
<
DomContentEventFiredEvent
>)
e
;
Console
.
WriteLine
(
"DomContentEvent: "
+
domContentEvent
.
Params
.
Timestamp
);
});
});
chromeSession
.
SendAsync
(
new
NavigateCommand
// you might never see this, but that's what an event is ... right?
chromeSession
.
Subscribe
<
Protocol
.
Page
.
FrameStartedLoadingEvent
>((
o
,
e
)
=>
{
{
Url
=
"http://www.google.com"
var
frameStartedLoadingEvent
=
(
Event
<
FrameStartedLoadingEvent
>)
e
;
Console
.
WriteLine
(
"FrameStartedLoading: "
+
frameStartedLoadingEvent
.
Params
.
FrameId
);
});
});
Console
.
ReadLine
();
Console
.
ReadLine
();
}
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment