Best Puppeteer-sharp code snippet using PuppeteerSharp.Mobile.DeviceDescriptor
DeviceDescriptors.cs
Source:DeviceDescriptors.cs
...3{4 /// <summary>5 /// Device descriptors.6 /// </summary>7 public static class DeviceDescriptors8 {9 private static readonly Dictionary<DeviceDescriptorName, DeviceDescriptor> Devices = new Dictionary<DeviceDescriptorName, DeviceDescriptor>10 {11 [DeviceDescriptorName.BlackberryPlayBook] = new DeviceDescriptor12 {13 Name = "Blackberry PlayBook",14 UserAgent = "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+",15 ViewPort = new ViewPortOptions16 {17 Width = 600,18 Height = 1024,19 DeviceScaleFactor = 1,20 IsMobile = true,21 HasTouch = true,22 IsLandscape = false23 }24 },25 [DeviceDescriptorName.BlackBerryZ30] = new DeviceDescriptor26 {27 Name = "BlackBerry Z30",28 UserAgent = "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+",29 ViewPort = new ViewPortOptions30 {31 Width = 360,32 Height = 640,33 DeviceScaleFactor = 2,34 IsMobile = true,35 HasTouch = true,36 IsLandscape = false37 }38 },39 [DeviceDescriptorName.BlackBerryZ30Landscape] = new DeviceDescriptor40 {41 Name = "BlackBerry Z30 landscape",42 UserAgent = "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+",43 ViewPort = new ViewPortOptions44 {45 Width = 640,46 Height = 360,47 DeviceScaleFactor = 2,48 IsMobile = true,49 HasTouch = true,50 IsLandscape = true51 }52 },53 [DeviceDescriptorName.GalaxyNote3] = new DeviceDescriptor54 {55 Name = "Galaxy Note 3",56 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",57 ViewPort = new ViewPortOptions58 {59 Width = 360,60 Height = 640,61 DeviceScaleFactor = 3,62 IsMobile = true,63 HasTouch = true,64 IsLandscape = false65 }66 },67 [DeviceDescriptorName.GalaxyNote3Landscape] = new DeviceDescriptor68 {69 Name = "Galaxy Note 3 landscape",70 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",71 ViewPort = new ViewPortOptions72 {73 Width = 640,74 Height = 360,75 DeviceScaleFactor = 3,76 IsMobile = true,77 HasTouch = true,78 IsLandscape = true79 }80 },81 [DeviceDescriptorName.GalaxyNoteII] = new DeviceDescriptor82 {83 Name = "Galaxy Note II",84 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",85 ViewPort = new ViewPortOptions86 {87 Width = 360,88 Height = 640,89 DeviceScaleFactor = 2,90 IsMobile = true,91 HasTouch = true,92 IsLandscape = false93 }94 },95 [DeviceDescriptorName.GalaxyNoteIILandscape] = new DeviceDescriptor96 {97 Name = "Galaxy Note II landscape",98 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",99 ViewPort = new ViewPortOptions100 {101 Width = 640,102 Height = 360,103 DeviceScaleFactor = 2,104 IsMobile = true,105 HasTouch = true,106 IsLandscape = true107 }108 },109 [DeviceDescriptorName.GalaxySIII] = new DeviceDescriptor110 {111 Name = "Galaxy S III",112 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",113 ViewPort = new ViewPortOptions114 {115 Width = 360,116 Height = 640,117 DeviceScaleFactor = 2,118 IsMobile = true,119 HasTouch = true,120 IsLandscape = false121 }122 },123 [DeviceDescriptorName.GalaxySIIILandscape] = new DeviceDescriptor124 {125 Name = "Galaxy S III landscape",126 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",127 ViewPort = new ViewPortOptions128 {129 Width = 640,130 Height = 360,131 DeviceScaleFactor = 2,132 IsMobile = true,133 HasTouch = true,134 IsLandscape = true135 }136 },137 [DeviceDescriptorName.GalaxyS5] = new DeviceDescriptor138 {139 Name = "Galaxy S5",140 UserAgent = "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",141 ViewPort = new ViewPortOptions142 {143 Width = 360,144 Height = 640,145 DeviceScaleFactor = 3,146 IsMobile = true,147 HasTouch = true,148 IsLandscape = false149 }150 },151 [DeviceDescriptorName.GalaxyS5Landscape] = new DeviceDescriptor152 {153 Name = "Galaxy S5 landscape",154 UserAgent = "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",155 ViewPort = new ViewPortOptions156 {157 Width = 640,158 Height = 360,159 DeviceScaleFactor = 3,160 IsMobile = true,161 HasTouch = true,162 IsLandscape = true163 }164 },165 [DeviceDescriptorName.IPad] = new DeviceDescriptor166 {167 Name = "iPad",168 UserAgent = "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",169 ViewPort = new ViewPortOptions170 {171 Width = 768,172 Height = 1024,173 DeviceScaleFactor = 2,174 IsMobile = true,175 HasTouch = true,176 IsLandscape = false177 }178 },179 [DeviceDescriptorName.IPadLandscape] = new DeviceDescriptor180 {181 Name = "iPad landscape",182 UserAgent = "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",183 ViewPort = new ViewPortOptions184 {185 Width = 1024,186 Height = 768,187 DeviceScaleFactor = 2,188 IsMobile = true,189 HasTouch = true,190 IsLandscape = true191 }192 },193 [DeviceDescriptorName.IPadMini] = new DeviceDescriptor194 {195 Name = "iPad Mini",196 UserAgent = "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",197 ViewPort = new ViewPortOptions198 {199 Width = 768,200 Height = 1024,201 DeviceScaleFactor = 2,202 IsMobile = true,203 HasTouch = true,204 IsLandscape = false205 }206 },207 [DeviceDescriptorName.IPadMiniLandscape] = new DeviceDescriptor208 {209 Name = "iPad Mini landscape",210 UserAgent = "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",211 ViewPort = new ViewPortOptions212 {213 Width = 1024,214 Height = 768,215 DeviceScaleFactor = 2,216 IsMobile = true,217 HasTouch = true,218 IsLandscape = true219 }220 },221 [DeviceDescriptorName.IPadPro] = new DeviceDescriptor222 {223 Name = "iPad Pro",224 UserAgent = "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",225 ViewPort = new ViewPortOptions226 {227 Width = 1024,228 Height = 1366,229 DeviceScaleFactor = 2,230 IsMobile = true,231 HasTouch = true,232 IsLandscape = false233 }234 },235 [DeviceDescriptorName.IPadProLandscape] = new DeviceDescriptor236 {237 Name = "iPad Pro landscape",238 UserAgent = "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",239 ViewPort = new ViewPortOptions240 {241 Width = 1366,242 Height = 1024,243 DeviceScaleFactor = 2,244 IsMobile = true,245 HasTouch = true,246 IsLandscape = true247 }248 },249 [DeviceDescriptorName.IPhone4] = new DeviceDescriptor250 {251 Name = "iPhone 4",252 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",253 ViewPort = new ViewPortOptions254 {255 Width = 320,256 Height = 480,257 DeviceScaleFactor = 2,258 IsMobile = true,259 HasTouch = true,260 IsLandscape = false261 }262 },263 [DeviceDescriptorName.IPhone4Landscape] = new DeviceDescriptor264 {265 Name = "iPhone 4 landscape",266 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",267 ViewPort = new ViewPortOptions268 {269 Width = 480,270 Height = 320,271 DeviceScaleFactor = 2,272 IsMobile = true,273 HasTouch = true,274 IsLandscape = true275 }276 },277 [DeviceDescriptorName.IPhone5] = new DeviceDescriptor278 {279 Name = "iPhone 5",280 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",281 ViewPort = new ViewPortOptions282 {283 Width = 320,284 Height = 568,285 DeviceScaleFactor = 2,286 IsMobile = true,287 HasTouch = true,288 IsLandscape = false289 }290 },291 [DeviceDescriptorName.IPhone5Landscape] = new DeviceDescriptor292 {293 Name = "iPhone 5 landscape",294 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",295 ViewPort = new ViewPortOptions296 {297 Width = 568,298 Height = 320,299 DeviceScaleFactor = 2,300 IsMobile = true,301 HasTouch = true,302 IsLandscape = true303 }304 },305 [DeviceDescriptorName.IPhone6] = new DeviceDescriptor306 {307 Name = "iPhone 6",308 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",309 ViewPort = new ViewPortOptions310 {311 Width = 375,312 Height = 667,313 DeviceScaleFactor = 2,314 IsMobile = true,315 HasTouch = true,316 IsLandscape = false317 }318 },319 [DeviceDescriptorName.IPhone6Landscape] = new DeviceDescriptor320 {321 Name = "iPhone 6 landscape",322 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",323 ViewPort = new ViewPortOptions324 {325 Width = 667,326 Height = 375,327 DeviceScaleFactor = 2,328 IsMobile = true,329 HasTouch = true,330 IsLandscape = true331 }332 },333 [DeviceDescriptorName.IPhone6Plus] = new DeviceDescriptor334 {335 Name = "iPhone 6 Plus",336 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",337 ViewPort = new ViewPortOptions338 {339 Width = 414,340 Height = 736,341 DeviceScaleFactor = 3,342 IsMobile = true,343 HasTouch = true,344 IsLandscape = false345 }346 },347 [DeviceDescriptorName.IPhone6PlusLandscape] = new DeviceDescriptor348 {349 Name = "iPhone 6 Plus landscape",350 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1",351 ViewPort = new ViewPortOptions352 {353 Width = 736,354 Height = 414,355 DeviceScaleFactor = 3,356 IsMobile = true,357 HasTouch = true,358 IsLandscape = true359 }360 },361 [DeviceDescriptorName.IPhoneX] = new DeviceDescriptor362 {363 Name = "iPhone X",364 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",365 ViewPort = new ViewPortOptions366 {367 Width = 375,368 Height = 812,369 DeviceScaleFactor = 3,370 IsMobile = true,371 HasTouch = true,372 IsLandscape = false373 }374 },375 [DeviceDescriptorName.IPhoneXLandscape] = new DeviceDescriptor376 {377 Name = "iPhone X landscape",378 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",379 ViewPort = new ViewPortOptions380 {381 Width = 812,382 Height = 375,383 DeviceScaleFactor = 3,384 IsMobile = true,385 HasTouch = true,386 IsLandscape = true387 }388 },389 [DeviceDescriptorName.KindleFireHDX] = new DeviceDescriptor390 {391 Name = "Kindle Fire HDX",392 UserAgent = "Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",393 ViewPort = new ViewPortOptions394 {395 Width = 800,396 Height = 1280,397 DeviceScaleFactor = 2,398 IsMobile = true,399 HasTouch = true,400 IsLandscape = false401 }402 },403 [DeviceDescriptorName.KindleFireHDXLandscape] = new DeviceDescriptor404 {405 Name = "Kindle Fire HDX landscape",406 UserAgent = "Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",407 ViewPort = new ViewPortOptions408 {409 Width = 1280,410 Height = 800,411 DeviceScaleFactor = 2,412 IsMobile = true,413 HasTouch = true,414 IsLandscape = true415 }416 },417 [DeviceDescriptorName.LGOptimusL70] = new DeviceDescriptor418 {419 Name = "LG Optimus L70",420 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/%s Mobile Safari/537.36",421 ViewPort = new ViewPortOptions422 {423 Width = 384,424 Height = 640,425 DeviceScaleFactor = 1.25,426 IsMobile = true,427 HasTouch = true,428 IsLandscape = false429 }430 },431 [DeviceDescriptorName.LGOptimusL70Landscape] = new DeviceDescriptor432 {433 Name = "LG Optimus L70 landscape",434 UserAgent = "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/%s Mobile Safari/537.36",435 ViewPort = new ViewPortOptions436 {437 Width = 640,438 Height = 384,439 DeviceScaleFactor = 1.25,440 IsMobile = true,441 HasTouch = true,442 IsLandscape = true443 }444 },445 [DeviceDescriptorName.MicrosoftLumia550] = new DeviceDescriptor446 {447 Name = "Microsoft Lumia 550",448 UserAgent = "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/14.14263",449 ViewPort = new ViewPortOptions450 {451 Width = 640,452 Height = 360,453 DeviceScaleFactor = 2,454 IsMobile = true,455 HasTouch = true,456 IsLandscape = false457 }458 },459 [DeviceDescriptorName.MicrosoftLumia950] = new DeviceDescriptor460 {461 Name = "Microsoft Lumia 950",462 UserAgent = "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/14.14263",463 ViewPort = new ViewPortOptions464 {465 Width = 360,466 Height = 640,467 DeviceScaleFactor = 4,468 IsMobile = true,469 HasTouch = true,470 IsLandscape = false471 }472 },473 [DeviceDescriptorName.MicrosoftLumia950Landscape] = new DeviceDescriptor474 {475 Name = "Microsoft Lumia 950 landscape",476 UserAgent = "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/14.14263",477 ViewPort = new ViewPortOptions478 {479 Width = 640,480 Height = 360,481 DeviceScaleFactor = 4,482 IsMobile = true,483 HasTouch = true,484 IsLandscape = true485 }486 },487 [DeviceDescriptorName.Nexus10] = new DeviceDescriptor488 {489 Name = "Nexus 10",490 UserAgent = "Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",491 ViewPort = new ViewPortOptions492 {493 Width = 800,494 Height = 1280,495 DeviceScaleFactor = 2,496 IsMobile = true,497 HasTouch = true,498 IsLandscape = false499 }500 },501 [DeviceDescriptorName.Nexus10Landscape] = new DeviceDescriptor502 {503 Name = "Nexus 10 landscape",504 UserAgent = "Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",505 ViewPort = new ViewPortOptions506 {507 Width = 1280,508 Height = 800,509 DeviceScaleFactor = 2,510 IsMobile = true,511 HasTouch = true,512 IsLandscape = true513 }514 },515 [DeviceDescriptorName.Nexus4] = new DeviceDescriptor516 {517 Name = "Nexus 4",518 UserAgent = "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",519 ViewPort = new ViewPortOptions520 {521 Width = 384,522 Height = 640,523 DeviceScaleFactor = 2,524 IsMobile = true,525 HasTouch = true,526 IsLandscape = false527 }528 },529 [DeviceDescriptorName.Nexus4Landscape] = new DeviceDescriptor530 {531 Name = "Nexus 4 landscape",532 UserAgent = "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",533 ViewPort = new ViewPortOptions534 {535 Width = 640,536 Height = 384,537 DeviceScaleFactor = 2,538 IsMobile = true,539 HasTouch = true,540 IsLandscape = true541 }542 },543 [DeviceDescriptorName.Nexus5] = new DeviceDescriptor544 {545 Name = "Nexus 5",546 UserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",547 ViewPort = new ViewPortOptions548 {549 Width = 360,550 Height = 640,551 DeviceScaleFactor = 3,552 IsMobile = true,553 HasTouch = true,554 IsLandscape = false555 }556 },557 [DeviceDescriptorName.Nexus5Landscape] = new DeviceDescriptor558 {559 Name = "Nexus 5 landscape",560 UserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",561 ViewPort = new ViewPortOptions562 {563 Width = 640,564 Height = 360,565 DeviceScaleFactor = 3,566 IsMobile = true,567 HasTouch = true,568 IsLandscape = true569 }570 },571 [DeviceDescriptorName.Nexus5X] = new DeviceDescriptor572 {573 Name = "Nexus 5X",574 UserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",575 ViewPort = new ViewPortOptions576 {577 Width = 412,578 Height = 732,579 DeviceScaleFactor = 2.625,580 IsMobile = true,581 HasTouch = true,582 IsLandscape = false583 }584 },585 [DeviceDescriptorName.Nexus5XLandscape] = new DeviceDescriptor586 {587 Name = "Nexus 5X landscape",588 UserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",589 ViewPort = new ViewPortOptions590 {591 Width = 732,592 Height = 412,593 DeviceScaleFactor = 2.625,594 IsMobile = true,595 HasTouch = true,596 IsLandscape = true597 }598 },599 [DeviceDescriptorName.Nexus6] = new DeviceDescriptor600 {601 Name = "Nexus 6",602 UserAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",603 ViewPort = new ViewPortOptions604 {605 Width = 412,606 Height = 732,607 DeviceScaleFactor = 3.5,608 IsMobile = true,609 HasTouch = true,610 IsLandscape = false611 }612 },613 [DeviceDescriptorName.Nexus6Landscape] = new DeviceDescriptor614 {615 Name = "Nexus 6 landscape",616 UserAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",617 ViewPort = new ViewPortOptions618 {619 Width = 732,620 Height = 412,621 DeviceScaleFactor = 3.5,622 IsMobile = true,623 HasTouch = true,624 IsLandscape = true625 }626 },627 [DeviceDescriptorName.Nexus6P] = new DeviceDescriptor628 {629 Name = "Nexus 6P",630 UserAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",631 ViewPort = new ViewPortOptions632 {633 Width = 412,634 Height = 732,635 DeviceScaleFactor = 3.5,636 IsMobile = true,637 HasTouch = true,638 IsLandscape = false639 }640 },641 [DeviceDescriptorName.Nexus6PLandscape] = new DeviceDescriptor642 {643 Name = "Nexus 6P landscape",644 UserAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",645 ViewPort = new ViewPortOptions646 {647 Width = 732,648 Height = 412,649 DeviceScaleFactor = 3.5,650 IsMobile = true,651 HasTouch = true,652 IsLandscape = true653 }654 },655 [DeviceDescriptorName.Nexus7] = new DeviceDescriptor656 {657 Name = "Nexus 7",658 UserAgent = "Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",659 ViewPort = new ViewPortOptions660 {661 Width = 600,662 Height = 960,663 DeviceScaleFactor = 2,664 IsMobile = true,665 HasTouch = true,666 IsLandscape = false667 }668 },669 [DeviceDescriptorName.Nexus7Landscape] = new DeviceDescriptor670 {671 Name = "Nexus 7 landscape",672 UserAgent = "Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",673 ViewPort = new ViewPortOptions674 {675 Width = 960,676 Height = 600,677 DeviceScaleFactor = 2,678 IsMobile = true,679 HasTouch = true,680 IsLandscape = true681 }682 },683 [DeviceDescriptorName.NokiaLumia520] = new DeviceDescriptor684 {685 Name = "Nokia Lumia 520",686 UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",687 ViewPort = new ViewPortOptions688 {689 Width = 320,690 Height = 533,691 DeviceScaleFactor = 1.5,692 IsMobile = true,693 HasTouch = true,694 IsLandscape = false695 }696 },697 [DeviceDescriptorName.NokiaLumia520Landscape] = new DeviceDescriptor698 {699 Name = "Nokia Lumia 520 landscape",700 UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",701 ViewPort = new ViewPortOptions702 {703 Width = 533,704 Height = 320,705 DeviceScaleFactor = 1.5,706 IsMobile = true,707 HasTouch = true,708 IsLandscape = true709 }710 },711 [DeviceDescriptorName.NokiaN9] = new DeviceDescriptor712 {713 Name = "Nokia N9",714 UserAgent = "Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",715 ViewPort = new ViewPortOptions716 {717 Width = 480,718 Height = 854,719 DeviceScaleFactor = 1,720 IsMobile = true,721 HasTouch = true,722 IsLandscape = false723 }724 },725 [DeviceDescriptorName.NokiaN9Landscape] = new DeviceDescriptor726 {727 Name = "Nokia N9 landscape",728 UserAgent = "Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",729 ViewPort = new ViewPortOptions730 {731 Width = 854,732 Height = 480,733 DeviceScaleFactor = 1,734 IsMobile = true,735 HasTouch = true,736 IsLandscape = true737 }738 }739 };740 /// <summary>741 /// Get the specified device description.742 /// </summary>743 /// <returns>The device descriptor.</returns>744 /// <param name="name">Device Name.</param>745 public static DeviceDescriptor Get(DeviceDescriptorName name) => Devices[name];746 }747}...
PageServer.cs
Source:PageServer.cs
...169 var context = await browser.CreateIncognitoBrowserContextAsync();170 page = await context.NewPageAsync();171 ///å±è½ WebDriver æ£æµ172 await page.EvaluateFunctionOnNewDocumentAsync("function(){Object.defineProperty(navigator, 'webdriver', {get: () => undefined})}");173 DeviceDescriptor deviceOptions = Puppeteer.Devices.GetValueOrDefault(DeviceDescriptorName.IPhone7);174 await page.EmulateAsync(deviceOptions);175 await page.GoToAsync(Url);176 await page.WaitForTimeoutAsync(500);177 await GetPhoneCode(Phone, page);178 var seven = await page.EvaluateExpressionAsync("document.querySelectorAll('button[report-eventid=MLoginRegister_SMSReceiveCode]')[0].innerText");179 await page.ClickAsync("button[report-eventid='MLoginRegister_SMSReceiveCode']");180 await page.ClickAsync("input[type=checkbox]");181 await page.WaitForTimeoutAsync(500);182 string js = "document.body.outerText";183 var pageouterText = await page.EvaluateExpressionAsync(js);184 var pagetext = pageouterText.ToString();185 var data = await getCount(qlkey);186 if (pagetext.Contains("å®å
¨éªè¯") && !pagetext.Contains("éªè¯æå"))187 {...
Program.cs
Source:Program.cs
...9namespace PuppeteerSharp.DevicesFetcher10{11 class Program12 {13 const string DEVICES_URL = "https://raw.githubusercontent.com/puppeteer/puppeteer/master/src/common/DeviceDescriptors.ts";14 static readonly string deviceDescriptorsOutput = "../../../../PuppeteerSharp/Mobile/DeviceDescriptors.cs";15 static readonly string deviceDescriptorNameOutput = "../../../../PuppeteerSharp/Mobile/DeviceDescriptorName.cs";16 static async Task Main(string[] args)17 {18 var url = DEVICES_URL;19 if (args.Length > 0)20 {21 url = args[0];22 }23 Console.WriteLine($"GET {url}");24 var text = await HttpGET(url);25 const string DeviceArray = "Device[] = [";26 var startIndex = text.IndexOf(DeviceArray) + DeviceArray.Length;27 var endIndex = text.IndexOf("];", startIndex);28 var length = endIndex - startIndex;29 text = "[" + text.Substring(startIndex, length) + "]";30 Device[] devices;31 try32 {33 devices = JsonConvert.DeserializeObject<Device[]>(text);34 }35 catch (Exception ex)36 {37 Console.WriteLine($"FAILED: error parsing response - {ex.Message}");38 return;39 }40 WriteDeviceDescriptors(devices);41 WriteDeviceDescriptorName(devices);42 }43 static void WriteDeviceDescriptors(IEnumerable<Device> devices)44 {45 var builder = new StringBuilder();46 var begin = @"using System;47using System.Collections.Generic;48using System.Collections.ObjectModel;49namespace PuppeteerSharp.Mobile50{51 /// <summary>52 /// Device descriptors.53 /// </summary>54 public static class DeviceDescriptors55 {56 private static readonly Dictionary<DeviceDescriptorName, DeviceDescriptor> Devices = new Dictionary<DeviceDescriptorName, DeviceDescriptor>57 {58";59 var end = @"60 };61 private static Lazy<IReadOnlyDictionary<DeviceDescriptorName, DeviceDescriptor>> _readOnlyDevices =62 new Lazy<IReadOnlyDictionary<DeviceDescriptorName, DeviceDescriptor>>(() => new ReadOnlyDictionary<DeviceDescriptorName, DeviceDescriptor>(Devices));63 internal static IReadOnlyDictionary<DeviceDescriptorName, DeviceDescriptor> ToReadOnly() => _readOnlyDevices.Value;64 /// <summary>65 /// Get the specified device description.66 /// </summary>67 /// <returns>The device descriptor.</returns>68 /// <param name=""name"">Device Name.</param>69 [Obsolete(""Use Puppeteer.Devices instead"")]70 public static DeviceDescriptor Get(DeviceDescriptorName name) => Devices[name];71 }72}";73 builder.Append(begin);74 builder.AppendJoin(",\n", devices.Select(GenerateCsharpFromDevice));75 builder.Append(end);76 File.WriteAllText(deviceDescriptorsOutput, builder.ToString());77 }78 static void WriteDeviceDescriptorName(IEnumerable<Device> devices)79 {80 var builder = new StringBuilder();81 var begin = @"namespace PuppeteerSharp.Mobile82{83 /// <summary>84 /// Device descriptor name.85 /// </summary>86 public enum DeviceDescriptorName87 {";88 var end = @"89 }90}";91 builder.Append(begin);92 builder.AppendJoin(",", devices.Select(device =>93 {94 return $@"95 /// <summary>96 /// {device.Name}97 /// </summary>98 {DeviceNameToEnumValue(device)}";99 }));100 builder.Append(end);101 File.WriteAllText(deviceDescriptorNameOutput, builder.ToString());102 }103 static string GenerateCsharpFromDevice(Device device)104 {105 return $@" [DeviceDescriptorName.{DeviceNameToEnumValue(device)}] = new DeviceDescriptor106 {{107 Name = ""{device.Name}"",108 UserAgent = ""{device.UserAgent}"",109 ViewPort = new ViewPortOptions110 {{111 Width = {device.Viewport.Width},112 Height = {device.Viewport.Height},113 DeviceScaleFactor = {device.Viewport.DeviceScaleFactor},114 IsMobile = {device.Viewport.IsMobile.ToString().ToLower()},115 HasTouch = {device.Viewport.HasTouch.ToString().ToLower()},116 IsLandscape = {device.Viewport.IsLandscape.ToString().ToLower()}117 }}118 }}";119 }...
Puppeteer.cs
Source:Puppeteer.cs
...71 /// <param name="options">Options.</param>72 public static BrowserFetcher CreateBrowserFetcher(BrowserFetcherOptions options)73 => new BrowserFetcher(options);74 /// <summary>75 /// Returns a list of devices to be used with <seealso cref="Page.EmulateAsync(DeviceDescriptor)"/>. 76 /// </summary>77 /// <example>78 /// <code>79 ///<![CDATA[80 /// var iPhone = Puppeteer.Devices[DeviceDescriptorName.IPhone6];81 /// using(var page = await browser.NewPageAsync())82 /// {83 /// await page.EmulateAsync(iPhone);84 /// await page.goto('https://www.google.com');85 /// }86 /// ]]>87 /// </code>88 /// </example>89 public static IReadOnlyDictionary<DeviceDescriptorName, DeviceDescriptor> Devices => DeviceDescriptors.ToReadOnly();90 }91}...
TestConstants.cs
Source:TestConstants.cs
...17 public const string AboutBlank = "about:blank";18 public static readonly string CrossProcessHttpPrefix = "http://127.0.0.1:8907";19 public static readonly string EmptyPage = $"{ServerUrl}/empty.html";20 public static readonly string CrossProcessUrl = ServerIpUrl;21 public static readonly DeviceDescriptor IPhone = DeviceDescriptors.Get(DeviceDescriptorName.IPhone6);22 public static readonly DeviceDescriptor IPhone6Landscape = DeviceDescriptors.Get(DeviceDescriptorName.IPhone6Landscape);23 public static ILoggerFactory LoggerFactory { get; private set; }24 public static readonly string NestedFramesDumpResult = @"http://localhost:<PORT>/frames/nested-frames.html25 http://localhost:<PORT>/frames/two-frames.html26 http://localhost:<PORT>/frames/frame.html27 http://localhost:<PORT>/frames/frame.html28 http://localhost:<PORT>/frames/frame.html";29 public static LaunchOptions DefaultBrowserOptions() => new LaunchOptions30 {31 SlowMo = Convert.ToInt32(Environment.GetEnvironmentVariable("SLOW_MO")),32 Headless = Convert.ToBoolean(Environment.GetEnvironmentVariable("HEADLESS") ?? "true"),33 Args = new[] { "--no-sandbox" },34 Timeout = 0,35 KeepAliveInterval = 120,36 LogProcess = true...
PuppeteerEngine.cs
Source:PuppeteerEngine.cs
...21 }22 public async Task<Page> newPage()23 {24 var page = await _browser.NewPageAsync();25 DeviceDescriptor IPhone = DeviceDescriptors.Get(DeviceDescriptorName.IPhone6);26 var dic = new Dictionary<string, string>();27 dic.Add("Referer", _settings.Bet365.Url.MainPage.ToString());28 dic.Add("Accept-Encoding", "gzip, deflate, br");29 dic.Add("Accept-Language", "zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6");30 dic.Add("Connection", "keep-alive");31 await page.EmulateAsync(IPhone);32 await page.SetRequestInterceptionAsync(true);33 await page.SetExtraHttpHeadersAsync(dic);34 page.Request += async (sender, e) =>35 {36 if (e.Request.ResourceType == ResourceType.Image)37 await e.Request.AbortAsync();38 else39 await e.Request.ContinueAsync();...
TouchScreenTests.cs
Source:TouchScreenTests.cs
...8{9 [Collection(TestConstants.TestFixtureCollectionName)]10 public class TouchScreenTests : PuppeteerPageBaseTest11 {12 private readonly DeviceDescriptor _iPhone = Puppeteer.Devices[DeviceDescriptorName.IPhone6];13 public TouchScreenTests(ITestOutputHelper output) : base(output)14 {15 }16 [PuppeteerTest("touchscreen.spec.ts", "Touchscreen", "should tap the button")]17 [SkipBrowserFact(skipFirefox: true)]18 public async Task ShouldTapTheButton()19 {20 await Page.EmulateAsync(_iPhone);21 await Page.GoToAsync(TestConstants.ServerUrl + "/input/button.html");22 await Page.TapAsync("button");23 Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));24 }25 [PuppeteerTest("touchscreen.spec.ts", "Touchscreen", "should report touches")]26 [SkipBrowserFact(skipFirefox: true)]...
DeviceDescriptor.cs
Source:DeviceDescriptor.cs
2{3 /// <summary>4 /// Device descriptor.5 /// </summary>6 public class DeviceDescriptor7 {8 /// <summary>9 /// Device name.10 /// </summary>11 /// <value>The name.</value>12 public string Name { get; internal set; }13 /// <summary>14 /// User Agent15 /// </summary>16 /// <value>The user agent.</value>17 public string UserAgent { get; internal set; }18 /// <summary>19 /// ViewPort.20 /// </summary>...
DeviceDescriptor
Using AI Code Generation
1using PuppeteerSharp.Mobile;2using System;3using System.Collections.Generic;4using System.Text;5{6 {7 public string Name { get; set; }8 public string UserAgent { get; set; }9 public string Viewport { get; set; }10 public string DeviceScaleFactor { get; set; }11 public string IsMobile { get; set; }12 public string HasTouch { get; set; }13 public string IsLandscape { get; set; }14 }15}16using PuppeteerSharp.Mobile;17using System;18using System.Collections.Generic;19using System.Text;20{21 {22 public static DeviceDescriptor iPhone5 { get; set; }23 public static DeviceDescriptor iPhone6 { get; set; }24 public static DeviceDescriptor iPhone6Plus { get; set; }25 public static DeviceDescriptor iPhoneX { get; set; }26 public static DeviceDescriptor iPad { get; set; }27 public static DeviceDescriptor iPadPro { get; set; }28 public static DeviceDescriptor KindleFireHDX { get; set; }29 public static DeviceDescriptor Nexus10 { get; set; }30 public static DeviceDescriptor Nexus7 { get; set; }31 public static DeviceDescriptor GalaxyS5 { get; set; }32 public static DeviceDescriptor GalaxyNote3 { get; set; }33 public static DeviceDescriptor Lumia920 { get; set; }34 public static DeviceDescriptor LumiaNokia920 { get; set; }35 public static DeviceDescriptor BlackberryPlaybook { get; set; }36 public static DeviceDescriptor Nexus5X { get; set; }37 public static DeviceDescriptor Nexus6P { get; set; }38 public static DeviceDescriptor NexusPixel { get; set; }39 public static DeviceDescriptor NexusPixelXL { get; set; }40 public static DeviceDescriptor Nexus5 { get; set; }41 public static DeviceDescriptor Nexus6 { get; set; }42 public static DeviceDescriptor Nexus9 { get; set; }43 public static DeviceDescriptor GalaxySIII { get; set; }44 public static DeviceDescriptor GalaxyS5 { get; set; }45 public static DeviceDescriptor GalaxyS6 { get; set; }
DeviceDescriptor
Using AI Code Generation
1using PuppeteerSharp.Mobile;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 MainAsync(args).GetAwaiter().GetResult();12 }13 static async Task MainAsync(string[] args)14 {15 var deviceDescriptor = DeviceDescriptor.GetDeviceDescriptor("iPhone X");16 {17 Args = new string[] { "--no-sandbox", "--disable-setuid-sandbox" }18 };19 options.DefaultViewport = deviceDescriptor.ViewPort;20 var browser = await Puppeteer.LaunchAsync(options);21 var page = await browser.NewPageAsync();22 await Task.Delay(5000);23 await browser.CloseAsync();24 }25 }26}
DeviceDescriptor
Using AI Code Generation
1using PuppeteerSharp.Mobile;2using PuppeteerSharp.Mobile;3using PuppeteerSharp.Mobile;4using PuppeteerSharp.Mobile;5using PuppeteerSharp.Mobile;6using PuppeteerSharp.Mobile;7using PuppeteerSharp.Mobile;8using PuppeteerSharp.Mobile;9using PuppeteerSharp.Mobile;10using PuppeteerSharp.Mobile;11using PuppeteerSharp.Mobile;12using PuppeteerSharp.Mobile;13using PuppeteerSharp.Mobile;14using PuppeteerSharp.Mobile;15using PuppeteerSharp.Mobile;16using PuppeteerSharp.Mobile;17using PuppeteerSharp.Mobile;18using PuppeteerSharp.Mobile;19using PuppeteerSharp.Mobile;20using PuppeteerSharp.Mobile;21using PuppeteerSharp.Mobile;22using PuppeteerSharp.Mobile;23using PuppeteerSharp.Mobile;24using PuppeteerSharp.Mobile;25using PuppeteerSharp.Mobile;
DeviceDescriptor
Using AI Code Generation
1using PuppeteerSharp.Mobile;2using System.Threading.Tasks;3{4 {5 static async Task Main(string[] args)6 {7 {8 UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4",9 {10 }11 };12 {13 Args = new string[] {14 },15 };16 using (var browser = await Puppeteer.LaunchAsync(options))17 {18 using (var page = await browser.NewPageAsync())19 {20 await page.EmulateAsync(device);21 }22 }23 }24 }25}
DeviceDescriptor
Using AI Code Generation
1var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetDevice("iPhone X");2{3 Args = device.GetDefaultArgs(),4 ExecutablePath = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"5};6var browser = await Puppeteer.LaunchAsync(options);7var page = await browser.NewPageAsync();8await page.ScreenshotAsync("google.png");9await browser.CloseAsync();10var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetDevice("iPhone X");11{12 Args = device.GetDefaultArgs(),13 ExecutablePath = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"14};15var browser = await Puppeteer.LaunchAsync(options);16var page = await browser.NewPageAsync();17await page.ScreenshotAsync("google.png");18await browser.CloseAsync();19var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetDevice("iPhone X");20{21 Args = device.GetDefaultArgs(),22 ExecutablePath = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"23};24var browser = await Puppeteer.LaunchAsync(options);25var page = await browser.NewPageAsync();26await page.ScreenshotAsync("google.png");27await browser.CloseAsync();28var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetDevice("iPhone X");29{30 Args = device.GetDefaultArgs(),31 ExecutablePath = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"32};33var browser = await Puppeteer.LaunchAsync(options);34var page = await browser.NewPageAsync();
DeviceDescriptor
Using AI Code Generation
1var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetByName("iPhone 6");2{3 Args = new string[] { $"--window-size=375,667" },4};5var browser = await Puppeteer.LaunchAsync(options);6var page = await browser.NewPageAsync();7await page.EmulateAsync(device);8await page.ScreenshotAsync("google.png");9await browser.CloseAsync();10var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetByName("iPhone 6");11{12 Args = new string[] { $"--window-size=375,667" },13};14var browser = await Puppeteer.LaunchAsync(options);15var page = await browser.NewPageAsync();16await page.EmulateAsync(device);17await page.ScreenshotAsync("google.png");18await browser.CloseAsync();19var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetByName("iPhone 6");20{21 Args = new string[] { $"--window-size=375,667" },22};23var browser = await Puppeteer.LaunchAsync(options);24var page = await browser.NewPageAsync();25await page.EmulateAsync(device);26await page.ScreenshotAsync("google.png");27await browser.CloseAsync();28var device = PuppeteerSharp.Mobile.DeviceDescriptor.GetByName("iPhone 6");29{30 Args = new string[] { $"--window-size=375,667" },31};32var browser = await Puppeteer.LaunchAsync(options);33var page = await browser.NewPageAsync();34await page.EmulateAsync(device);35await page.ScreenshotAsync("google.png");36await browser.CloseAsync();
DeviceDescriptor
Using AI Code Generation
1var device = DeviceDescriptor.GetByName(DeviceName);2var options = new LaunchOptions { Headless = false, DefaultViewport = null };3var browser = await Puppeteer.LaunchAsync(options);4var context = await browser.CreateIncognitoBrowserContextAsync();5var page = await context.NewPageAsync(device);6await page.ScreenshotAsync("google.png");7await browser.CloseAsync();8var device = DeviceDescriptor.GetByName(DeviceName);9var options = new LaunchOptions { Headless = false, DefaultViewport = null };10var browser = await Puppeteer.LaunchAsync(options);11var page = await browser.NewPageAsync(device);12await page.ScreenshotAsync("google.png");13await browser.CloseAsync();14var device = DeviceDescriptor.GetByName(DeviceName);15var options = new LaunchOptions { Headless = false, DefaultViewport = null };16var browser = await Puppeteer.LaunchAsync(options);17var page = await browser.NewPageAsync(device);18await page.ScreenshotAsync("google.png");19await browser.CloseAsync();20var device = DeviceDescriptor.GetByName(DeviceName);21var options = new LaunchOptions { Headless = false, DefaultViewport = null };22var browser = await Puppeteer.LaunchAsync(options);23var page = await browser.NewPageAsync(device);24await page.ScreenshotAsync("google.png");25await browser.CloseAsync();26var device = DeviceDescriptor.GetByName(DeviceName);27var options = new LaunchOptions { Headless = false, DefaultViewport = null };28var browser = await Puppeteer.LaunchAsync(options);29var page = await browser.NewPageAsync(device);30await page.ScreenshotAsync("google.png");
DeviceDescriptor
Using AI Code Generation
1using PuppeteerSharp.Mobile;2using PuppeteerSharp;3{4 static async Task Main(string[] args)5 {6 var deviceDescriptor = PuppeteerSharp.Mobile.Devices.GetDevice("iPhone 6");7 {8 };9 using (var browser = await Puppeteer.LaunchAsync(options))10 {11 var page = await browser.NewPageAsync();12 await page.WaitForNavigationAsync();13 }14 }15}
DeviceDescriptor
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using PuppeteerSharp.Mobile;7{8 {9 static void Main(string[] args)10 {11 var device = DeviceDescriptor.GetByName("iPhone 6");12 Console.WriteLine(device.UserAgent);13 Console.WriteLine(device.Name);14 Console.ReadLine();15 }16 }17}18Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G36 Safari/601.1
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!