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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
|
// Package page provides the Chrome DevTools Protocol
// commands, types, and events for the Page domain.
//
// Actions and events related to the inspected page belong to the page
// domain.
//
// Generated by the cdproto-gen command.
package page
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"encoding/base64"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/debugger"
"github.com/chromedp/cdproto/dom"
"github.com/chromedp/cdproto/io"
"github.com/chromedp/cdproto/runtime"
)
// AddScriptToEvaluateOnNewDocumentParams evaluates given script in every
// frame upon creation (before loading frame's scripts).
type AddScriptToEvaluateOnNewDocumentParams struct {
Source string `json:"source"`
WorldName string `json:"worldName,omitempty"` // If specified, creates an isolated world with the given name and evaluates given script in it. This world name will be used as the ExecutionContextDescription::name when the corresponding event is emitted.
IncludeCommandLineAPI bool `json:"includeCommandLineAPI,omitempty"` // Specifies whether command line API should be available to the script, defaults to false.
}
// AddScriptToEvaluateOnNewDocument evaluates given script in every frame
// upon creation (before loading frame's scripts).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-addScriptToEvaluateOnNewDocument
//
// parameters:
//
// source
func AddScriptToEvaluateOnNewDocument(source string) *AddScriptToEvaluateOnNewDocumentParams {
return &AddScriptToEvaluateOnNewDocumentParams{
Source: source,
}
}
// WithWorldName if specified, creates an isolated world with the given name
// and evaluates given script in it. This world name will be used as the
// ExecutionContextDescription::name when the corresponding event is emitted.
func (p AddScriptToEvaluateOnNewDocumentParams) WithWorldName(worldName string) *AddScriptToEvaluateOnNewDocumentParams {
p.WorldName = worldName
return &p
}
// WithIncludeCommandLineAPI specifies whether command line API should be
// available to the script, defaults to false.
func (p AddScriptToEvaluateOnNewDocumentParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *AddScriptToEvaluateOnNewDocumentParams {
p.IncludeCommandLineAPI = includeCommandLineAPI
return &p
}
// AddScriptToEvaluateOnNewDocumentReturns return values.
type AddScriptToEvaluateOnNewDocumentReturns struct {
Identifier ScriptIdentifier `json:"identifier,omitempty"` // Identifier of the added script.
}
// Do executes Page.addScriptToEvaluateOnNewDocument against the provided context.
//
// returns:
//
// identifier - Identifier of the added script.
func (p *AddScriptToEvaluateOnNewDocumentParams) Do(ctx context.Context) (identifier ScriptIdentifier, err error) {
// execute
var res AddScriptToEvaluateOnNewDocumentReturns
err = cdp.Execute(ctx, CommandAddScriptToEvaluateOnNewDocument, p, &res)
if err != nil {
return "", err
}
return res.Identifier, nil
}
// BringToFrontParams brings page to front (activates tab).
type BringToFrontParams struct{}
// BringToFront brings page to front (activates tab).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-bringToFront
func BringToFront() *BringToFrontParams {
return &BringToFrontParams{}
}
// Do executes Page.bringToFront against the provided context.
func (p *BringToFrontParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandBringToFront, nil, nil)
}
// CaptureScreenshotParams capture page screenshot.
type CaptureScreenshotParams struct {
Format CaptureScreenshotFormat `json:"format,omitempty"` // Image compression format (defaults to png).
Quality int64 `json:"quality,omitempty"` // Compression quality from range [0..100] (jpeg only).
Clip *Viewport `json:"clip,omitempty"` // Capture the screenshot of a given region only.
FromSurface bool `json:"fromSurface,omitempty"` // Capture the screenshot from the surface, rather than the view. Defaults to true.
CaptureBeyondViewport bool `json:"captureBeyondViewport,omitempty"` // Capture the screenshot beyond the viewport. Defaults to false.
OptimizeForSpeed bool `json:"optimizeForSpeed,omitempty"` // Optimize image encoding for speed, not for resulting size (defaults to false)
}
// CaptureScreenshot capture page screenshot.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-captureScreenshot
//
// parameters:
func CaptureScreenshot() *CaptureScreenshotParams {
return &CaptureScreenshotParams{}
}
// WithFormat image compression format (defaults to png).
func (p CaptureScreenshotParams) WithFormat(format CaptureScreenshotFormat) *CaptureScreenshotParams {
p.Format = format
return &p
}
// WithQuality compression quality from range [0..100] (jpeg only).
func (p CaptureScreenshotParams) WithQuality(quality int64) *CaptureScreenshotParams {
p.Quality = quality
return &p
}
// WithClip capture the screenshot of a given region only.
func (p CaptureScreenshotParams) WithClip(clip *Viewport) *CaptureScreenshotParams {
p.Clip = clip
return &p
}
// WithFromSurface capture the screenshot from the surface, rather than the
// view. Defaults to true.
func (p CaptureScreenshotParams) WithFromSurface(fromSurface bool) *CaptureScreenshotParams {
p.FromSurface = fromSurface
return &p
}
// WithCaptureBeyondViewport capture the screenshot beyond the viewport.
// Defaults to false.
func (p CaptureScreenshotParams) WithCaptureBeyondViewport(captureBeyondViewport bool) *CaptureScreenshotParams {
p.CaptureBeyondViewport = captureBeyondViewport
return &p
}
// WithOptimizeForSpeed optimize image encoding for speed, not for resulting
// size (defaults to false).
func (p CaptureScreenshotParams) WithOptimizeForSpeed(optimizeForSpeed bool) *CaptureScreenshotParams {
p.OptimizeForSpeed = optimizeForSpeed
return &p
}
// CaptureScreenshotReturns return values.
type CaptureScreenshotReturns struct {
Data string `json:"data,omitempty"` // Base64-encoded image data.
}
// Do executes Page.captureScreenshot against the provided context.
//
// returns:
//
// data - Base64-encoded image data.
func (p *CaptureScreenshotParams) Do(ctx context.Context) (data []byte, err error) {
// execute
var res CaptureScreenshotReturns
err = cdp.Execute(ctx, CommandCaptureScreenshot, p, &res)
if err != nil {
return nil, err
}
// decode
var dec []byte
dec, err = base64.StdEncoding.DecodeString(res.Data)
if err != nil {
return nil, err
}
return dec, nil
}
// CaptureSnapshotParams returns a snapshot of the page as a string. For
// MHTML format, the serialization includes iframes, shadow DOM, external
// resources, and element-inline styles.
type CaptureSnapshotParams struct {
Format CaptureSnapshotFormat `json:"format,omitempty"` // Format (defaults to mhtml).
}
// CaptureSnapshot returns a snapshot of the page as a string. For MHTML
// format, the serialization includes iframes, shadow DOM, external resources,
// and element-inline styles.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-captureSnapshot
//
// parameters:
func CaptureSnapshot() *CaptureSnapshotParams {
return &CaptureSnapshotParams{}
}
// WithFormat format (defaults to mhtml).
func (p CaptureSnapshotParams) WithFormat(format CaptureSnapshotFormat) *CaptureSnapshotParams {
p.Format = format
return &p
}
// CaptureSnapshotReturns return values.
type CaptureSnapshotReturns struct {
Data string `json:"data,omitempty"` // Serialized page data.
}
// Do executes Page.captureSnapshot against the provided context.
//
// returns:
//
// data - Serialized page data.
func (p *CaptureSnapshotParams) Do(ctx context.Context) (data string, err error) {
// execute
var res CaptureSnapshotReturns
err = cdp.Execute(ctx, CommandCaptureSnapshot, p, &res)
if err != nil {
return "", err
}
return res.Data, nil
}
// CreateIsolatedWorldParams creates an isolated world for the given frame.
type CreateIsolatedWorldParams struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame in which the isolated world should be created.
WorldName string `json:"worldName,omitempty"` // An optional name which is reported in the Execution Context.
GrantUniveralAccess bool `json:"grantUniveralAccess,omitempty"` // Whether or not universal access should be granted to the isolated world. This is a powerful option, use with caution.
}
// CreateIsolatedWorld creates an isolated world for the given frame.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-createIsolatedWorld
//
// parameters:
//
// frameID - Id of the frame in which the isolated world should be created.
func CreateIsolatedWorld(frameID cdp.FrameID) *CreateIsolatedWorldParams {
return &CreateIsolatedWorldParams{
FrameID: frameID,
}
}
// WithWorldName an optional name which is reported in the Execution Context.
func (p CreateIsolatedWorldParams) WithWorldName(worldName string) *CreateIsolatedWorldParams {
p.WorldName = worldName
return &p
}
// WithGrantUniveralAccess whether or not universal access should be granted
// to the isolated world. This is a powerful option, use with caution.
func (p CreateIsolatedWorldParams) WithGrantUniveralAccess(grantUniveralAccess bool) *CreateIsolatedWorldParams {
p.GrantUniveralAccess = grantUniveralAccess
return &p
}
// CreateIsolatedWorldReturns return values.
type CreateIsolatedWorldReturns struct {
ExecutionContextID runtime.ExecutionContextID `json:"executionContextId,omitempty"` // Execution context of the isolated world.
}
// Do executes Page.createIsolatedWorld against the provided context.
//
// returns:
//
// executionContextID - Execution context of the isolated world.
func (p *CreateIsolatedWorldParams) Do(ctx context.Context) (executionContextID runtime.ExecutionContextID, err error) {
// execute
var res CreateIsolatedWorldReturns
err = cdp.Execute(ctx, CommandCreateIsolatedWorld, p, &res)
if err != nil {
return 0, err
}
return res.ExecutionContextID, nil
}
// DisableParams disables page domain notifications.
type DisableParams struct{}
// Disable disables page domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Page.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables page domain notifications.
type EnableParams struct{}
// Enable enables page domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Page.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// GetAppManifestParams [no description].
type GetAppManifestParams struct{}
// GetAppManifest [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getAppManifest
func GetAppManifest() *GetAppManifestParams {
return &GetAppManifestParams{}
}
// GetAppManifestReturns return values.
type GetAppManifestReturns struct {
URL string `json:"url,omitempty"` // Manifest location.
Errors []*AppManifestError `json:"errors,omitempty"`
Data string `json:"data,omitempty"` // Manifest content.
Parsed *AppManifestParsedProperties `json:"parsed,omitempty"` // Parsed manifest properties
}
// Do executes Page.getAppManifest against the provided context.
//
// returns:
//
// url - Manifest location.
// errors
// data - Manifest content.
// parsed - Parsed manifest properties
func (p *GetAppManifestParams) Do(ctx context.Context) (url string, errors []*AppManifestError, data string, parsed *AppManifestParsedProperties, err error) {
// execute
var res GetAppManifestReturns
err = cdp.Execute(ctx, CommandGetAppManifest, nil, &res)
if err != nil {
return "", nil, "", nil, err
}
return res.URL, res.Errors, res.Data, res.Parsed, nil
}
// GetInstallabilityErrorsParams [no description].
type GetInstallabilityErrorsParams struct{}
// GetInstallabilityErrors [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getInstallabilityErrors
func GetInstallabilityErrors() *GetInstallabilityErrorsParams {
return &GetInstallabilityErrorsParams{}
}
// GetInstallabilityErrorsReturns return values.
type GetInstallabilityErrorsReturns struct {
InstallabilityErrors []*InstallabilityError `json:"installabilityErrors,omitempty"`
}
// Do executes Page.getInstallabilityErrors against the provided context.
//
// returns:
//
// installabilityErrors
func (p *GetInstallabilityErrorsParams) Do(ctx context.Context) (installabilityErrors []*InstallabilityError, err error) {
// execute
var res GetInstallabilityErrorsReturns
err = cdp.Execute(ctx, CommandGetInstallabilityErrors, nil, &res)
if err != nil {
return nil, err
}
return res.InstallabilityErrors, nil
}
// GetManifestIconsParams [no description].
type GetManifestIconsParams struct{}
// GetManifestIcons [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getManifestIcons
func GetManifestIcons() *GetManifestIconsParams {
return &GetManifestIconsParams{}
}
// GetManifestIconsReturns return values.
type GetManifestIconsReturns struct {
PrimaryIcon string `json:"primaryIcon,omitempty"`
}
// Do executes Page.getManifestIcons against the provided context.
//
// returns:
//
// primaryIcon
func (p *GetManifestIconsParams) Do(ctx context.Context) (primaryIcon []byte, err error) {
// execute
var res GetManifestIconsReturns
err = cdp.Execute(ctx, CommandGetManifestIcons, nil, &res)
if err != nil {
return nil, err
}
// decode
var dec []byte
dec, err = base64.StdEncoding.DecodeString(res.PrimaryIcon)
if err != nil {
return nil, err
}
return dec, nil
}
// GetAppIDParams returns the unique (PWA) app id. Only returns values if the
// feature flag 'WebAppEnableManifestId' is enabled.
type GetAppIDParams struct{}
// GetAppID returns the unique (PWA) app id. Only returns values if the
// feature flag 'WebAppEnableManifestId' is enabled.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getAppId
func GetAppID() *GetAppIDParams {
return &GetAppIDParams{}
}
// GetAppIDReturns return values.
type GetAppIDReturns struct {
AppID string `json:"appId,omitempty"` // App id, either from manifest's id attribute or computed from start_url
RecommendedID string `json:"recommendedId,omitempty"` // Recommendation for manifest's id attribute to match current id computed from start_url
}
// Do executes Page.getAppId against the provided context.
//
// returns:
//
// appID - App id, either from manifest's id attribute or computed from start_url
// recommendedID - Recommendation for manifest's id attribute to match current id computed from start_url
func (p *GetAppIDParams) Do(ctx context.Context) (appID string, recommendedID string, err error) {
// execute
var res GetAppIDReturns
err = cdp.Execute(ctx, CommandGetAppID, nil, &res)
if err != nil {
return "", "", err
}
return res.AppID, res.RecommendedID, nil
}
// GetAdScriptIDParams [no description].
type GetAdScriptIDParams struct {
FrameID cdp.FrameID `json:"frameId"`
}
// GetAdScriptID [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getAdScriptId
//
// parameters:
//
// frameID
func GetAdScriptID(frameID cdp.FrameID) *GetAdScriptIDParams {
return &GetAdScriptIDParams{
FrameID: frameID,
}
}
// GetAdScriptIDReturns return values.
type GetAdScriptIDReturns struct {
AdScriptID *AdScriptID `json:"adScriptId,omitempty"` // Identifies the bottom-most script which caused the frame to be labelled as an ad. Only sent if frame is labelled as an ad and id is available.
}
// Do executes Page.getAdScriptId against the provided context.
//
// returns:
//
// adScriptID - Identifies the bottom-most script which caused the frame to be labelled as an ad. Only sent if frame is labelled as an ad and id is available.
func (p *GetAdScriptIDParams) Do(ctx context.Context) (adScriptID *AdScriptID, err error) {
// execute
var res GetAdScriptIDReturns
err = cdp.Execute(ctx, CommandGetAdScriptID, p, &res)
if err != nil {
return nil, err
}
return res.AdScriptID, nil
}
// GetFrameTreeParams returns present frame tree structure.
type GetFrameTreeParams struct{}
// GetFrameTree returns present frame tree structure.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getFrameTree
func GetFrameTree() *GetFrameTreeParams {
return &GetFrameTreeParams{}
}
// GetFrameTreeReturns return values.
type GetFrameTreeReturns struct {
FrameTree *FrameTree `json:"frameTree,omitempty"` // Present frame tree structure.
}
// Do executes Page.getFrameTree against the provided context.
//
// returns:
//
// frameTree - Present frame tree structure.
func (p *GetFrameTreeParams) Do(ctx context.Context) (frameTree *FrameTree, err error) {
// execute
var res GetFrameTreeReturns
err = cdp.Execute(ctx, CommandGetFrameTree, nil, &res)
if err != nil {
return nil, err
}
return res.FrameTree, nil
}
// GetLayoutMetricsParams returns metrics relating to the layouting of the
// page, such as viewport bounds/scale.
type GetLayoutMetricsParams struct{}
// GetLayoutMetrics returns metrics relating to the layouting of the page,
// such as viewport bounds/scale.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getLayoutMetrics
func GetLayoutMetrics() *GetLayoutMetricsParams {
return &GetLayoutMetricsParams{}
}
// GetLayoutMetricsReturns return values.
type GetLayoutMetricsReturns struct {
LayoutViewport *LayoutViewport `json:"layoutViewport"` // Deprecated metrics relating to the layout viewport. Is in device pixels. Use cssLayoutViewport instead.
VisualViewport *VisualViewport `json:"visualViewport"` // Deprecated metrics relating to the visual viewport. Is in device pixels. Use cssVisualViewport instead.
ContentSize *dom.Rect `json:"contentSize"` // Deprecated size of scrollable area. Is in DP. Use cssContentSize instead.
CSSLayoutViewport *LayoutViewport `json:"cssLayoutViewport"` // Metrics relating to the layout viewport in CSS pixels.
CSSVisualViewport *VisualViewport `json:"cssVisualViewport"` // Metrics relating to the visual viewport in CSS pixels.
CSSContentSize *dom.Rect `json:"cssContentSize"` // Size of scrollable area in CSS pixels.
}
// Do executes Page.getLayoutMetrics against the provided context.
//
// returns:
//
// layoutViewport - Deprecated metrics relating to the layout viewport. Is in device pixels. Use cssLayoutViewport instead.
// visualViewport - Deprecated metrics relating to the visual viewport. Is in device pixels. Use cssVisualViewport instead.
// contentSize - Deprecated size of scrollable area. Is in DP. Use cssContentSize instead.
// cssLayoutViewport - Metrics relating to the layout viewport in CSS pixels.
// cssVisualViewport - Metrics relating to the visual viewport in CSS pixels.
// cssContentSize - Size of scrollable area in CSS pixels.
func (p *GetLayoutMetricsParams) Do(ctx context.Context) (layoutViewport *LayoutViewport, visualViewport *VisualViewport, contentSize *dom.Rect, cssLayoutViewport *LayoutViewport, cssVisualViewport *VisualViewport, cssContentSize *dom.Rect, err error) {
// execute
var res GetLayoutMetricsReturns
err = cdp.Execute(ctx, CommandGetLayoutMetrics, nil, &res)
if err != nil {
return nil, nil, nil, nil, nil, nil, err
}
return res.LayoutViewport, res.VisualViewport, res.ContentSize, res.CSSLayoutViewport, res.CSSVisualViewport, res.CSSContentSize, nil
}
// GetNavigationHistoryParams returns navigation history for the current
// page.
type GetNavigationHistoryParams struct{}
// GetNavigationHistory returns navigation history for the current page.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getNavigationHistory
func GetNavigationHistory() *GetNavigationHistoryParams {
return &GetNavigationHistoryParams{}
}
// GetNavigationHistoryReturns return values.
type GetNavigationHistoryReturns struct {
CurrentIndex int64 `json:"currentIndex,omitempty"` // Index of the current navigation history entry.
Entries []*NavigationEntry `json:"entries,omitempty"` // Array of navigation history entries.
}
// Do executes Page.getNavigationHistory against the provided context.
//
// returns:
//
// currentIndex - Index of the current navigation history entry.
// entries - Array of navigation history entries.
func (p *GetNavigationHistoryParams) Do(ctx context.Context) (currentIndex int64, entries []*NavigationEntry, err error) {
// execute
var res GetNavigationHistoryReturns
err = cdp.Execute(ctx, CommandGetNavigationHistory, nil, &res)
if err != nil {
return 0, nil, err
}
return res.CurrentIndex, res.Entries, nil
}
// ResetNavigationHistoryParams resets navigation history for the current
// page.
type ResetNavigationHistoryParams struct{}
// ResetNavigationHistory resets navigation history for the current page.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-resetNavigationHistory
func ResetNavigationHistory() *ResetNavigationHistoryParams {
return &ResetNavigationHistoryParams{}
}
// Do executes Page.resetNavigationHistory against the provided context.
func (p *ResetNavigationHistoryParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandResetNavigationHistory, nil, nil)
}
// GetResourceContentParams returns content of the given resource.
type GetResourceContentParams struct {
FrameID cdp.FrameID `json:"frameId"` // Frame id to get resource for.
URL string `json:"url"` // URL of the resource to get content for.
}
// GetResourceContent returns content of the given resource.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getResourceContent
//
// parameters:
//
// frameID - Frame id to get resource for.
// url - URL of the resource to get content for.
func GetResourceContent(frameID cdp.FrameID, url string) *GetResourceContentParams {
return &GetResourceContentParams{
FrameID: frameID,
URL: url,
}
}
// GetResourceContentReturns return values.
type GetResourceContentReturns struct {
Content string `json:"content,omitempty"` // Resource content.
Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was served as base64.
}
// Do executes Page.getResourceContent against the provided context.
//
// returns:
//
// content - Resource content.
func (p *GetResourceContentParams) Do(ctx context.Context) (content []byte, err error) {
// execute
var res GetResourceContentReturns
err = cdp.Execute(ctx, CommandGetResourceContent, p, &res)
if err != nil {
return nil, err
}
// decode
var dec []byte
if res.Base64encoded {
dec, err = base64.StdEncoding.DecodeString(res.Content)
if err != nil {
return nil, err
}
} else {
dec = []byte(res.Content)
}
return dec, nil
}
// GetResourceTreeParams returns present frame / resource tree structure.
type GetResourceTreeParams struct{}
// GetResourceTree returns present frame / resource tree structure.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getResourceTree
func GetResourceTree() *GetResourceTreeParams {
return &GetResourceTreeParams{}
}
// GetResourceTreeReturns return values.
type GetResourceTreeReturns struct {
FrameTree *FrameResourceTree `json:"frameTree,omitempty"` // Present frame / resource tree structure.
}
// Do executes Page.getResourceTree against the provided context.
//
// returns:
//
// frameTree - Present frame / resource tree structure.
func (p *GetResourceTreeParams) Do(ctx context.Context) (frameTree *FrameResourceTree, err error) {
// execute
var res GetResourceTreeReturns
err = cdp.Execute(ctx, CommandGetResourceTree, nil, &res)
if err != nil {
return nil, err
}
return res.FrameTree, nil
}
// HandleJavaScriptDialogParams accepts or dismisses a JavaScript initiated
// dialog (alert, confirm, prompt, or onbeforeunload).
type HandleJavaScriptDialogParams struct {
Accept bool `json:"accept"` // Whether to accept or dismiss the dialog.
PromptText string `json:"promptText,omitempty"` // The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog.
}
// HandleJavaScriptDialog accepts or dismisses a JavaScript initiated dialog
// (alert, confirm, prompt, or onbeforeunload).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-handleJavaScriptDialog
//
// parameters:
//
// accept - Whether to accept or dismiss the dialog.
func HandleJavaScriptDialog(accept bool) *HandleJavaScriptDialogParams {
return &HandleJavaScriptDialogParams{
Accept: accept,
}
}
// WithPromptText the text to enter into the dialog prompt before accepting.
// Used only if this is a prompt dialog.
func (p HandleJavaScriptDialogParams) WithPromptText(promptText string) *HandleJavaScriptDialogParams {
p.PromptText = promptText
return &p
}
// Do executes Page.handleJavaScriptDialog against the provided context.
func (p *HandleJavaScriptDialogParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandHandleJavaScriptDialog, p, nil)
}
// NavigateParams navigates current page to the given URL.
type NavigateParams struct {
URL string `json:"url"` // URL to navigate the page to.
Referrer string `json:"referrer,omitempty"` // Referrer URL.
TransitionType TransitionType `json:"transitionType,omitempty"` // Intended transition type.
FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame id to navigate, if not specified navigates the top frame.
ReferrerPolicy ReferrerPolicy `json:"referrerPolicy,omitempty"` // Referrer-policy used for the navigation.
}
// Navigate navigates current page to the given URL.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-navigate
//
// parameters:
//
// url - URL to navigate the page to.
func Navigate(url string) *NavigateParams {
return &NavigateParams{
URL: url,
}
}
// WithReferrer referrer URL.
func (p NavigateParams) WithReferrer(referrer string) *NavigateParams {
p.Referrer = referrer
return &p
}
// WithTransitionType intended transition type.
func (p NavigateParams) WithTransitionType(transitionType TransitionType) *NavigateParams {
p.TransitionType = transitionType
return &p
}
// WithFrameID frame id to navigate, if not specified navigates the top
// frame.
func (p NavigateParams) WithFrameID(frameID cdp.FrameID) *NavigateParams {
p.FrameID = frameID
return &p
}
// WithReferrerPolicy referrer-policy used for the navigation.
func (p NavigateParams) WithReferrerPolicy(referrerPolicy ReferrerPolicy) *NavigateParams {
p.ReferrerPolicy = referrerPolicy
return &p
}
// NavigateReturns return values.
type NavigateReturns struct {
FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame id that has navigated (or failed to navigate)
LoaderID cdp.LoaderID `json:"loaderId,omitempty"` // Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.
ErrorText string `json:"errorText,omitempty"` // User friendly error message, present if and only if navigation has failed.
}
// Do executes Page.navigate against the provided context.
//
// returns:
//
// frameID - Frame id that has navigated (or failed to navigate)
// loaderID - Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.
// errorText - User friendly error message, present if and only if navigation has failed.
func (p *NavigateParams) Do(ctx context.Context) (frameID cdp.FrameID, loaderID cdp.LoaderID, errorText string, err error) {
// execute
var res NavigateReturns
err = cdp.Execute(ctx, CommandNavigate, p, &res)
if err != nil {
return "", "", "", err
}
return res.FrameID, res.LoaderID, res.ErrorText, nil
}
// NavigateToHistoryEntryParams navigates current page to the given history
// entry.
type NavigateToHistoryEntryParams struct {
EntryID int64 `json:"entryId"` // Unique id of the entry to navigate to.
}
// NavigateToHistoryEntry navigates current page to the given history entry.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-navigateToHistoryEntry
//
// parameters:
//
// entryID - Unique id of the entry to navigate to.
func NavigateToHistoryEntry(entryID int64) *NavigateToHistoryEntryParams {
return &NavigateToHistoryEntryParams{
EntryID: entryID,
}
}
// Do executes Page.navigateToHistoryEntry against the provided context.
func (p *NavigateToHistoryEntryParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandNavigateToHistoryEntry, p, nil)
}
// PrintToPDFParams print page as PDF.
type PrintToPDFParams struct {
Landscape bool `json:"landscape,omitempty"` // Paper orientation. Defaults to false.
DisplayHeaderFooter bool `json:"displayHeaderFooter,omitempty"` // Display header and footer. Defaults to false.
PrintBackground bool `json:"printBackground,omitempty"` // Print background graphics. Defaults to false.
Scale float64 `json:"scale,omitempty"` // Scale of the webpage rendering. Defaults to 1.
PaperWidth float64 `json:"paperWidth,omitempty"` // Paper width in inches. Defaults to 8.5 inches.
PaperHeight float64 `json:"paperHeight,omitempty"` // Paper height in inches. Defaults to 11 inches.
MarginTop float64 `json:"marginTop"` // Top margin in inches. Defaults to 1cm (~0.4 inches).
MarginBottom float64 `json:"marginBottom"` // Bottom margin in inches. Defaults to 1cm (~0.4 inches).
MarginLeft float64 `json:"marginLeft"` // Left margin in inches. Defaults to 1cm (~0.4 inches).
MarginRight float64 `json:"marginRight"` // Right margin in inches. Defaults to 1cm (~0.4 inches).
PageRanges string `json:"pageRanges,omitempty"` // Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are printed in the document order, not in the order specified, and no more than once. Defaults to empty string, which implies the entire document is printed. The page numbers are quietly capped to actual page count of the document, and ranges beyond the end of the document are ignored. If this results in no pages to print, an error is reported. It is an error to specify a range with start greater than end.
HeaderTemplate string `json:"headerTemplate,omitempty"` // HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: - date: formatted print date - title: document title - url: document location - pageNumber: current page number - totalPages: total pages in the document For example, <span class=title></span> would generate span containing the title.
FooterTemplate string `json:"footerTemplate,omitempty"` // HTML template for the print footer. Should use the same format as the headerTemplate.
PreferCSSPageSize bool `json:"preferCSSPageSize,omitempty"` // Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
TransferMode PrintToPDFTransferMode `json:"transferMode,omitempty"` // return as stream
}
// PrintToPDF print page as PDF.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF
//
// parameters:
func PrintToPDF() *PrintToPDFParams {
return &PrintToPDFParams{}
}
// WithLandscape paper orientation. Defaults to false.
func (p PrintToPDFParams) WithLandscape(landscape bool) *PrintToPDFParams {
p.Landscape = landscape
return &p
}
// WithDisplayHeaderFooter display header and footer. Defaults to false.
func (p PrintToPDFParams) WithDisplayHeaderFooter(displayHeaderFooter bool) *PrintToPDFParams {
p.DisplayHeaderFooter = displayHeaderFooter
return &p
}
// WithPrintBackground print background graphics. Defaults to false.
func (p PrintToPDFParams) WithPrintBackground(printBackground bool) *PrintToPDFParams {
p.PrintBackground = printBackground
return &p
}
// WithScale scale of the webpage rendering. Defaults to 1.
func (p PrintToPDFParams) WithScale(scale float64) *PrintToPDFParams {
p.Scale = scale
return &p
}
// WithPaperWidth paper width in inches. Defaults to 8.5 inches.
func (p PrintToPDFParams) WithPaperWidth(paperWidth float64) *PrintToPDFParams {
p.PaperWidth = paperWidth
return &p
}
// WithPaperHeight paper height in inches. Defaults to 11 inches.
func (p PrintToPDFParams) WithPaperHeight(paperHeight float64) *PrintToPDFParams {
p.PaperHeight = paperHeight
return &p
}
// WithMarginTop top margin in inches. Defaults to 1cm (~0.4 inches).
func (p PrintToPDFParams) WithMarginTop(marginTop float64) *PrintToPDFParams {
p.MarginTop = marginTop
return &p
}
// WithMarginBottom bottom margin in inches. Defaults to 1cm (~0.4 inches).
func (p PrintToPDFParams) WithMarginBottom(marginBottom float64) *PrintToPDFParams {
p.MarginBottom = marginBottom
return &p
}
// WithMarginLeft left margin in inches. Defaults to 1cm (~0.4 inches).
func (p PrintToPDFParams) WithMarginLeft(marginLeft float64) *PrintToPDFParams {
p.MarginLeft = marginLeft
return &p
}
// WithMarginRight right margin in inches. Defaults to 1cm (~0.4 inches).
func (p PrintToPDFParams) WithMarginRight(marginRight float64) *PrintToPDFParams {
p.MarginRight = marginRight
return &p
}
// WithPageRanges paper ranges to print, one based, e.g., '1-5, 8, 11-13'.
// Pages are printed in the document order, not in the order specified, and no
// more than once. Defaults to empty string, which implies the entire document
// is printed. The page numbers are quietly capped to actual page count of the
// document, and ranges beyond the end of the document are ignored. If this
// results in no pages to print, an error is reported. It is an error to specify
// a range with start greater than end.
func (p PrintToPDFParams) WithPageRanges(pageRanges string) *PrintToPDFParams {
p.PageRanges = pageRanges
return &p
}
// WithHeaderTemplate HTML template for the print header. Should be valid
// HTML markup with following classes used to inject printing values into them:
// - date: formatted print date - title: document title - url: document location
// - pageNumber: current page number - totalPages: total pages in the document
// For example, <span class=title></span> would generate span containing the
// title.
func (p PrintToPDFParams) WithHeaderTemplate(headerTemplate string) *PrintToPDFParams {
p.HeaderTemplate = headerTemplate
return &p
}
// WithFooterTemplate HTML template for the print footer. Should use the same
// format as the headerTemplate.
func (p PrintToPDFParams) WithFooterTemplate(footerTemplate string) *PrintToPDFParams {
p.FooterTemplate = footerTemplate
return &p
}
// WithPreferCSSPageSize whether or not to prefer page size as defined by
// css. Defaults to false, in which case the content will be scaled to fit the
// paper size.
func (p PrintToPDFParams) WithPreferCSSPageSize(preferCSSPageSize bool) *PrintToPDFParams {
p.PreferCSSPageSize = preferCSSPageSize
return &p
}
// WithTransferMode return as stream.
func (p PrintToPDFParams) WithTransferMode(transferMode PrintToPDFTransferMode) *PrintToPDFParams {
p.TransferMode = transferMode
return &p
}
// PrintToPDFReturns return values.
type PrintToPDFReturns struct {
Data string `json:"data,omitempty"` // Base64-encoded pdf data. Empty if |returnAsStream| is specified.
Stream io.StreamHandle `json:"stream,omitempty"` // A handle of the stream that holds resulting PDF data.
}
// Do executes Page.printToPDF against the provided context.
//
// returns:
//
// data - Base64-encoded pdf data. Empty if |returnAsStream| is specified.
// stream - A handle of the stream that holds resulting PDF data.
func (p *PrintToPDFParams) Do(ctx context.Context) (data []byte, stream io.StreamHandle, err error) {
// execute
var res PrintToPDFReturns
err = cdp.Execute(ctx, CommandPrintToPDF, p, &res)
if err != nil {
return nil, "", err
}
// decode
var dec []byte
dec, err = base64.StdEncoding.DecodeString(res.Data)
if err != nil {
return nil, "", err
}
return dec, res.Stream, nil
}
// ReloadParams reloads given page optionally ignoring the cache.
type ReloadParams struct {
IgnoreCache bool `json:"ignoreCache,omitempty"` // If true, browser cache is ignored (as if the user pressed Shift+refresh).
ScriptToEvaluateOnLoad string `json:"scriptToEvaluateOnLoad,omitempty"` // If set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.
}
// Reload reloads given page optionally ignoring the cache.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-reload
//
// parameters:
func Reload() *ReloadParams {
return &ReloadParams{}
}
// WithIgnoreCache if true, browser cache is ignored (as if the user pressed
// Shift+refresh).
func (p ReloadParams) WithIgnoreCache(ignoreCache bool) *ReloadParams {
p.IgnoreCache = ignoreCache
return &p
}
// WithScriptToEvaluateOnLoad if set, the script will be injected into all
// frames of the inspected page after reload. Argument will be ignored if
// reloading dataURL origin.
func (p ReloadParams) WithScriptToEvaluateOnLoad(scriptToEvaluateOnLoad string) *ReloadParams {
p.ScriptToEvaluateOnLoad = scriptToEvaluateOnLoad
return &p
}
// Do executes Page.reload against the provided context.
func (p *ReloadParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandReload, p, nil)
}
// RemoveScriptToEvaluateOnNewDocumentParams removes given script from the
// list.
type RemoveScriptToEvaluateOnNewDocumentParams struct {
Identifier ScriptIdentifier `json:"identifier"`
}
// RemoveScriptToEvaluateOnNewDocument removes given script from the list.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-removeScriptToEvaluateOnNewDocument
//
// parameters:
//
// identifier
func RemoveScriptToEvaluateOnNewDocument(identifier ScriptIdentifier) *RemoveScriptToEvaluateOnNewDocumentParams {
return &RemoveScriptToEvaluateOnNewDocumentParams{
Identifier: identifier,
}
}
// Do executes Page.removeScriptToEvaluateOnNewDocument against the provided context.
func (p *RemoveScriptToEvaluateOnNewDocumentParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveScriptToEvaluateOnNewDocument, p, nil)
}
// ScreencastFrameAckParams acknowledges that a screencast frame has been
// received by the frontend.
type ScreencastFrameAckParams struct {
SessionID int64 `json:"sessionId"` // Frame number.
}
// ScreencastFrameAck acknowledges that a screencast frame has been received
// by the frontend.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-screencastFrameAck
//
// parameters:
//
// sessionID - Frame number.
func ScreencastFrameAck(sessionID int64) *ScreencastFrameAckParams {
return &ScreencastFrameAckParams{
SessionID: sessionID,
}
}
// Do executes Page.screencastFrameAck against the provided context.
func (p *ScreencastFrameAckParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandScreencastFrameAck, p, nil)
}
// SearchInResourceParams searches for given string in resource content.
type SearchInResourceParams struct {
FrameID cdp.FrameID `json:"frameId"` // Frame id for resource to search in.
URL string `json:"url"` // URL of the resource to search in.
Query string `json:"query"` // String to search for.
CaseSensitive bool `json:"caseSensitive,omitempty"` // If true, search is case sensitive.
IsRegex bool `json:"isRegex,omitempty"` // If true, treats string parameter as regex.
}
// SearchInResource searches for given string in resource content.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-searchInResource
//
// parameters:
//
// frameID - Frame id for resource to search in.
// url - URL of the resource to search in.
// query - String to search for.
func SearchInResource(frameID cdp.FrameID, url string, query string) *SearchInResourceParams {
return &SearchInResourceParams{
FrameID: frameID,
URL: url,
Query: query,
}
}
// WithCaseSensitive if true, search is case sensitive.
func (p SearchInResourceParams) WithCaseSensitive(caseSensitive bool) *SearchInResourceParams {
p.CaseSensitive = caseSensitive
return &p
}
// WithIsRegex if true, treats string parameter as regex.
func (p SearchInResourceParams) WithIsRegex(isRegex bool) *SearchInResourceParams {
p.IsRegex = isRegex
return &p
}
// SearchInResourceReturns return values.
type SearchInResourceReturns struct {
Result []*debugger.SearchMatch `json:"result,omitempty"` // List of search matches.
}
// Do executes Page.searchInResource against the provided context.
//
// returns:
//
// result - List of search matches.
func (p *SearchInResourceParams) Do(ctx context.Context) (result []*debugger.SearchMatch, err error) {
// execute
var res SearchInResourceReturns
err = cdp.Execute(ctx, CommandSearchInResource, p, &res)
if err != nil {
return nil, err
}
return res.Result, nil
}
// SetAdBlockingEnabledParams enable Chrome's experimental ad filter on all
// sites.
type SetAdBlockingEnabledParams struct {
Enabled bool `json:"enabled"` // Whether to block ads.
}
// SetAdBlockingEnabled enable Chrome's experimental ad filter on all sites.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setAdBlockingEnabled
//
// parameters:
//
// enabled - Whether to block ads.
func SetAdBlockingEnabled(enabled bool) *SetAdBlockingEnabledParams {
return &SetAdBlockingEnabledParams{
Enabled: enabled,
}
}
// Do executes Page.setAdBlockingEnabled against the provided context.
func (p *SetAdBlockingEnabledParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetAdBlockingEnabled, p, nil)
}
// SetBypassCSPParams enable page Content Security Policy by-passing.
type SetBypassCSPParams struct {
Enabled bool `json:"enabled"` // Whether to bypass page CSP.
}
// SetBypassCSP enable page Content Security Policy by-passing.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setBypassCSP
//
// parameters:
//
// enabled - Whether to bypass page CSP.
func SetBypassCSP(enabled bool) *SetBypassCSPParams {
return &SetBypassCSPParams{
Enabled: enabled,
}
}
// Do executes Page.setBypassCSP against the provided context.
func (p *SetBypassCSPParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetBypassCSP, p, nil)
}
// GetPermissionsPolicyStateParams get Permissions Policy state on given
// frame.
type GetPermissionsPolicyStateParams struct {
FrameID cdp.FrameID `json:"frameId"`
}
// GetPermissionsPolicyState get Permissions Policy state on given frame.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getPermissionsPolicyState
//
// parameters:
//
// frameID
func GetPermissionsPolicyState(frameID cdp.FrameID) *GetPermissionsPolicyStateParams {
return &GetPermissionsPolicyStateParams{
FrameID: frameID,
}
}
// GetPermissionsPolicyStateReturns return values.
type GetPermissionsPolicyStateReturns struct {
States []*PermissionsPolicyFeatureState `json:"states,omitempty"`
}
// Do executes Page.getPermissionsPolicyState against the provided context.
//
// returns:
//
// states
func (p *GetPermissionsPolicyStateParams) Do(ctx context.Context) (states []*PermissionsPolicyFeatureState, err error) {
// execute
var res GetPermissionsPolicyStateReturns
err = cdp.Execute(ctx, CommandGetPermissionsPolicyState, p, &res)
if err != nil {
return nil, err
}
return res.States, nil
}
// GetOriginTrialsParams get Origin Trials on given frame.
type GetOriginTrialsParams struct {
FrameID cdp.FrameID `json:"frameId"`
}
// GetOriginTrials get Origin Trials on given frame.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getOriginTrials
//
// parameters:
//
// frameID
func GetOriginTrials(frameID cdp.FrameID) *GetOriginTrialsParams {
return &GetOriginTrialsParams{
FrameID: frameID,
}
}
// GetOriginTrialsReturns return values.
type GetOriginTrialsReturns struct {
OriginTrials []*cdp.OriginTrial `json:"originTrials,omitempty"`
}
// Do executes Page.getOriginTrials against the provided context.
//
// returns:
//
// originTrials
func (p *GetOriginTrialsParams) Do(ctx context.Context) (originTrials []*cdp.OriginTrial, err error) {
// execute
var res GetOriginTrialsReturns
err = cdp.Execute(ctx, CommandGetOriginTrials, p, &res)
if err != nil {
return nil, err
}
return res.OriginTrials, nil
}
// SetFontFamiliesParams set generic font families.
type SetFontFamiliesParams struct {
FontFamilies *FontFamilies `json:"fontFamilies"` // Specifies font families to set. If a font family is not specified, it won't be changed.
ForScripts []*ScriptFontFamilies `json:"forScripts,omitempty"` // Specifies font families to set for individual scripts.
}
// SetFontFamilies set generic font families.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setFontFamilies
//
// parameters:
//
// fontFamilies - Specifies font families to set. If a font family is not specified, it won't be changed.
func SetFontFamilies(fontFamilies *FontFamilies) *SetFontFamiliesParams {
return &SetFontFamiliesParams{
FontFamilies: fontFamilies,
}
}
// WithForScripts specifies font families to set for individual scripts.
func (p SetFontFamiliesParams) WithForScripts(forScripts []*ScriptFontFamilies) *SetFontFamiliesParams {
p.ForScripts = forScripts
return &p
}
// Do executes Page.setFontFamilies against the provided context.
func (p *SetFontFamiliesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetFontFamilies, p, nil)
}
// SetFontSizesParams set default font sizes.
type SetFontSizesParams struct {
FontSizes *FontSizes `json:"fontSizes"` // Specifies font sizes to set. If a font size is not specified, it won't be changed.
}
// SetFontSizes set default font sizes.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setFontSizes
//
// parameters:
//
// fontSizes - Specifies font sizes to set. If a font size is not specified, it won't be changed.
func SetFontSizes(fontSizes *FontSizes) *SetFontSizesParams {
return &SetFontSizesParams{
FontSizes: fontSizes,
}
}
// Do executes Page.setFontSizes against the provided context.
func (p *SetFontSizesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetFontSizes, p, nil)
}
// SetDocumentContentParams sets given markup as the document's HTML.
type SetDocumentContentParams struct {
FrameID cdp.FrameID `json:"frameId"` // Frame id to set HTML for.
HTML string `json:"html"` // HTML content to set.
}
// SetDocumentContent sets given markup as the document's HTML.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setDocumentContent
//
// parameters:
//
// frameID - Frame id to set HTML for.
// html - HTML content to set.
func SetDocumentContent(frameID cdp.FrameID, html string) *SetDocumentContentParams {
return &SetDocumentContentParams{
FrameID: frameID,
HTML: html,
}
}
// Do executes Page.setDocumentContent against the provided context.
func (p *SetDocumentContentParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDocumentContent, p, nil)
}
// SetLifecycleEventsEnabledParams controls whether page will emit lifecycle
// events.
type SetLifecycleEventsEnabledParams struct {
Enabled bool `json:"enabled"` // If true, starts emitting lifecycle events.
}
// SetLifecycleEventsEnabled controls whether page will emit lifecycle
// events.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setLifecycleEventsEnabled
//
// parameters:
//
// enabled - If true, starts emitting lifecycle events.
func SetLifecycleEventsEnabled(enabled bool) *SetLifecycleEventsEnabledParams {
return &SetLifecycleEventsEnabledParams{
Enabled: enabled,
}
}
// Do executes Page.setLifecycleEventsEnabled against the provided context.
func (p *SetLifecycleEventsEnabledParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetLifecycleEventsEnabled, p, nil)
}
// StartScreencastParams starts sending each frame using the screencastFrame
// event.
type StartScreencastParams struct {
Format ScreencastFormat `json:"format,omitempty"` // Image compression format.
Quality int64 `json:"quality,omitempty"` // Compression quality from range [0..100].
MaxWidth int64 `json:"maxWidth,omitempty"` // Maximum screenshot width.
MaxHeight int64 `json:"maxHeight,omitempty"` // Maximum screenshot height.
EveryNthFrame int64 `json:"everyNthFrame,omitempty"` // Send every n-th frame.
}
// StartScreencast starts sending each frame using the screencastFrame event.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-startScreencast
//
// parameters:
func StartScreencast() *StartScreencastParams {
return &StartScreencastParams{}
}
// WithFormat image compression format.
func (p StartScreencastParams) WithFormat(format ScreencastFormat) *StartScreencastParams {
p.Format = format
return &p
}
// WithQuality compression quality from range [0..100].
func (p StartScreencastParams) WithQuality(quality int64) *StartScreencastParams {
p.Quality = quality
return &p
}
// WithMaxWidth maximum screenshot width.
func (p StartScreencastParams) WithMaxWidth(maxWidth int64) *StartScreencastParams {
p.MaxWidth = maxWidth
return &p
}
// WithMaxHeight maximum screenshot height.
func (p StartScreencastParams) WithMaxHeight(maxHeight int64) *StartScreencastParams {
p.MaxHeight = maxHeight
return &p
}
// WithEveryNthFrame send every n-th frame.
func (p StartScreencastParams) WithEveryNthFrame(everyNthFrame int64) *StartScreencastParams {
p.EveryNthFrame = everyNthFrame
return &p
}
// Do executes Page.startScreencast against the provided context.
func (p *StartScreencastParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartScreencast, p, nil)
}
// StopLoadingParams force the page stop all navigations and pending resource
// fetches.
type StopLoadingParams struct{}
// StopLoading force the page stop all navigations and pending resource
// fetches.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-stopLoading
func StopLoading() *StopLoadingParams {
return &StopLoadingParams{}
}
// Do executes Page.stopLoading against the provided context.
func (p *StopLoadingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopLoading, nil, nil)
}
// CrashParams crashes renderer on the IO thread, generates minidumps.
type CrashParams struct{}
// Crash crashes renderer on the IO thread, generates minidumps.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-crash
func Crash() *CrashParams {
return &CrashParams{}
}
// Do executes Page.crash against the provided context.
func (p *CrashParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandCrash, nil, nil)
}
// CloseParams tries to close page, running its beforeunload hooks, if any.
type CloseParams struct{}
// Close tries to close page, running its beforeunload hooks, if any.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-close
func Close() *CloseParams {
return &CloseParams{}
}
// Do executes Page.close against the provided context.
func (p *CloseParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClose, nil, nil)
}
// SetWebLifecycleStateParams tries to update the web lifecycle state of the
// page. It will transition the page to the given state according to:
// https://github.com/WICG/web-lifecycle/.
type SetWebLifecycleStateParams struct {
State SetWebLifecycleStateState `json:"state"` // Target lifecycle state
}
// SetWebLifecycleState tries to update the web lifecycle state of the page.
// It will transition the page to the given state according to:
// https://github.com/WICG/web-lifecycle/.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setWebLifecycleState
//
// parameters:
//
// state - Target lifecycle state
func SetWebLifecycleState(state SetWebLifecycleStateState) *SetWebLifecycleStateParams {
return &SetWebLifecycleStateParams{
State: state,
}
}
// Do executes Page.setWebLifecycleState against the provided context.
func (p *SetWebLifecycleStateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetWebLifecycleState, p, nil)
}
// StopScreencastParams stops sending each frame in the screencastFrame.
type StopScreencastParams struct{}
// StopScreencast stops sending each frame in the screencastFrame.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-stopScreencast
func StopScreencast() *StopScreencastParams {
return &StopScreencastParams{}
}
// Do executes Page.stopScreencast against the provided context.
func (p *StopScreencastParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopScreencast, nil, nil)
}
// ProduceCompilationCacheParams requests backend to produce compilation
// cache for the specified scripts. scripts are appeneded to the list of scripts
// for which the cache would be produced. The list may be reset during page
// navigation. When script with a matching URL is encountered, the cache is
// optionally produced upon backend discretion, based on internal heuristics.
// See also: Page.compilationCacheProduced.
type ProduceCompilationCacheParams struct {
Scripts []*CompilationCacheParams `json:"scripts"`
}
// ProduceCompilationCache requests backend to produce compilation cache for
// the specified scripts. scripts are appeneded to the list of scripts for which
// the cache would be produced. The list may be reset during page navigation.
// When script with a matching URL is encountered, the cache is optionally
// produced upon backend discretion, based on internal heuristics. See also:
// Page.compilationCacheProduced.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-produceCompilationCache
//
// parameters:
//
// scripts
func ProduceCompilationCache(scripts []*CompilationCacheParams) *ProduceCompilationCacheParams {
return &ProduceCompilationCacheParams{
Scripts: scripts,
}
}
// Do executes Page.produceCompilationCache against the provided context.
func (p *ProduceCompilationCacheParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandProduceCompilationCache, p, nil)
}
// AddCompilationCacheParams seeds compilation cache for given url.
// Compilation cache does not survive cross-process navigation.
type AddCompilationCacheParams struct {
URL string `json:"url"`
Data string `json:"data"` // Base64-encoded data
}
// AddCompilationCache seeds compilation cache for given url. Compilation
// cache does not survive cross-process navigation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-addCompilationCache
//
// parameters:
//
// url
// data - Base64-encoded data
func AddCompilationCache(url string, data string) *AddCompilationCacheParams {
return &AddCompilationCacheParams{
URL: url,
Data: data,
}
}
// Do executes Page.addCompilationCache against the provided context.
func (p *AddCompilationCacheParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandAddCompilationCache, p, nil)
}
// ClearCompilationCacheParams clears seeded compilation cache.
type ClearCompilationCacheParams struct{}
// ClearCompilationCache clears seeded compilation cache.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-clearCompilationCache
func ClearCompilationCache() *ClearCompilationCacheParams {
return &ClearCompilationCacheParams{}
}
// Do executes Page.clearCompilationCache against the provided context.
func (p *ClearCompilationCacheParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClearCompilationCache, nil, nil)
}
// SetSPCTransactionModeParams sets the Secure Payment Confirmation
// transaction mode.
// https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode.
type SetSPCTransactionModeParams struct {
Mode SetSPCTransactionModeMode `json:"mode"`
}
// SetSPCTransactionMode sets the Secure Payment Confirmation transaction
// mode.
// https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setSPCTransactionMode
//
// parameters:
//
// mode
func SetSPCTransactionMode(mode SetSPCTransactionModeMode) *SetSPCTransactionModeParams {
return &SetSPCTransactionModeParams{
Mode: mode,
}
}
// Do executes Page.setSPCTransactionMode against the provided context.
func (p *SetSPCTransactionModeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetSPCTransactionMode, p, nil)
}
// GenerateTestReportParams generates a report for testing.
type GenerateTestReportParams struct {
Message string `json:"message"` // Message to be displayed in the report.
Group string `json:"group,omitempty"` // Specifies the endpoint group to deliver the report to.
}
// GenerateTestReport generates a report for testing.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-generateTestReport
//
// parameters:
//
// message - Message to be displayed in the report.
func GenerateTestReport(message string) *GenerateTestReportParams {
return &GenerateTestReportParams{
Message: message,
}
}
// WithGroup specifies the endpoint group to deliver the report to.
func (p GenerateTestReportParams) WithGroup(group string) *GenerateTestReportParams {
p.Group = group
return &p
}
// Do executes Page.generateTestReport against the provided context.
func (p *GenerateTestReportParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandGenerateTestReport, p, nil)
}
// WaitForDebuggerParams pauses page execution. Can be resumed using generic
// Runtime.runIfWaitingForDebugger.
type WaitForDebuggerParams struct{}
// WaitForDebugger pauses page execution. Can be resumed using generic
// Runtime.runIfWaitingForDebugger.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-waitForDebugger
func WaitForDebugger() *WaitForDebuggerParams {
return &WaitForDebuggerParams{}
}
// Do executes Page.waitForDebugger against the provided context.
func (p *WaitForDebuggerParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandWaitForDebugger, nil, nil)
}
// SetInterceptFileChooserDialogParams intercept file chooser requests and
// transfer control to protocol clients. When file chooser interception is
// enabled, native file chooser dialog is not shown. Instead, a protocol event
// Page.fileChooserOpened is emitted.
type SetInterceptFileChooserDialogParams struct {
Enabled bool `json:"enabled"`
}
// SetInterceptFileChooserDialog intercept file chooser requests and transfer
// control to protocol clients. When file chooser interception is enabled,
// native file chooser dialog is not shown. Instead, a protocol event
// Page.fileChooserOpened is emitted.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setInterceptFileChooserDialog
//
// parameters:
//
// enabled
func SetInterceptFileChooserDialog(enabled bool) *SetInterceptFileChooserDialogParams {
return &SetInterceptFileChooserDialogParams{
Enabled: enabled,
}
}
// Do executes Page.setInterceptFileChooserDialog against the provided context.
func (p *SetInterceptFileChooserDialogParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetInterceptFileChooserDialog, p, nil)
}
// Command names.
const (
CommandAddScriptToEvaluateOnNewDocument = "Page.addScriptToEvaluateOnNewDocument"
CommandBringToFront = "Page.bringToFront"
CommandCaptureScreenshot = "Page.captureScreenshot"
CommandCaptureSnapshot = "Page.captureSnapshot"
CommandCreateIsolatedWorld = "Page.createIsolatedWorld"
CommandDisable = "Page.disable"
CommandEnable = "Page.enable"
CommandGetAppManifest = "Page.getAppManifest"
CommandGetInstallabilityErrors = "Page.getInstallabilityErrors"
CommandGetManifestIcons = "Page.getManifestIcons"
CommandGetAppID = "Page.getAppId"
CommandGetAdScriptID = "Page.getAdScriptId"
CommandGetFrameTree = "Page.getFrameTree"
CommandGetLayoutMetrics = "Page.getLayoutMetrics"
CommandGetNavigationHistory = "Page.getNavigationHistory"
CommandResetNavigationHistory = "Page.resetNavigationHistory"
CommandGetResourceContent = "Page.getResourceContent"
CommandGetResourceTree = "Page.getResourceTree"
CommandHandleJavaScriptDialog = "Page.handleJavaScriptDialog"
CommandNavigate = "Page.navigate"
CommandNavigateToHistoryEntry = "Page.navigateToHistoryEntry"
CommandPrintToPDF = "Page.printToPDF"
CommandReload = "Page.reload"
CommandRemoveScriptToEvaluateOnNewDocument = "Page.removeScriptToEvaluateOnNewDocument"
CommandScreencastFrameAck = "Page.screencastFrameAck"
CommandSearchInResource = "Page.searchInResource"
CommandSetAdBlockingEnabled = "Page.setAdBlockingEnabled"
CommandSetBypassCSP = "Page.setBypassCSP"
CommandGetPermissionsPolicyState = "Page.getPermissionsPolicyState"
CommandGetOriginTrials = "Page.getOriginTrials"
CommandSetFontFamilies = "Page.setFontFamilies"
CommandSetFontSizes = "Page.setFontSizes"
CommandSetDocumentContent = "Page.setDocumentContent"
CommandSetLifecycleEventsEnabled = "Page.setLifecycleEventsEnabled"
CommandStartScreencast = "Page.startScreencast"
CommandStopLoading = "Page.stopLoading"
CommandCrash = "Page.crash"
CommandClose = "Page.close"
CommandSetWebLifecycleState = "Page.setWebLifecycleState"
CommandStopScreencast = "Page.stopScreencast"
CommandProduceCompilationCache = "Page.produceCompilationCache"
CommandAddCompilationCache = "Page.addCompilationCache"
CommandClearCompilationCache = "Page.clearCompilationCache"
CommandSetSPCTransactionMode = "Page.setSPCTransactionMode"
CommandGenerateTestReport = "Page.generateTestReport"
CommandWaitForDebugger = "Page.waitForDebugger"
CommandSetInterceptFileChooserDialog = "Page.setInterceptFileChooserDialog"
)
|