881
881
< li class ="md-nav__item ">
882
882
< a href ="#cdp-mode-usage " class ="md-nav__link ">
883
883
< span class ="md-ellipsis ">
884
- 🐙 CDP Mode usage
884
+ 🐙 CDP Mode Usage
885
885
</ span >
886
886
</ a >
887
887
888
888
</ li >
889
889
890
890
< li class ="md-nav__item ">
891
- < a href ="#here-are-some -common-sbcdp-methods " class ="md-nav__link ">
891
+ < a href ="#here-are-a-few -common-sbcdp-methods " class ="md-nav__link ">
892
892
< span class ="md-ellipsis ">
893
- 🐙 Here are some common sb.cdp methods
893
+ 🐙 Here are a few common sb.cdp methods
894
894
</ span >
895
895
</ a >
896
896
897
897
</ li >
898
898
899
899
< li class ="md-nav__item ">
900
- < a href ="#cdp-mode-examples " class ="md-nav__link ">
900
+ < a href ="#cdp-mode-examples-seleniumbaseexamplescdp_mode " class ="md-nav__link ">
901
901
< span class ="md-ellipsis ">
902
- 🐙 CDP Mode examples
903
- </ span >
904
- </ a >
905
-
906
- </ li >
907
-
908
- < li class ="md-nav__item ">
909
- < a href ="#example-1-pokemon-site-using-incapsulaimperva-protection-with-invisible-recaptcha " class ="md-nav__link ">
910
- < span class ="md-ellipsis ">
911
- 🔖 Example 1: (Pokemon site using Incapsula/Imperva protection with invisible reCAPTCHA)
912
- </ span >
913
- </ a >
914
-
915
- </ li >
916
-
917
- < li class ="md-nav__item ">
918
- < a href ="#example-2-hyatt-site-using-kasada-protection " class ="md-nav__link ">
919
- < span class ="md-ellipsis ">
920
- 🔖 Example 2: (Hyatt site using Kasada protection)
921
- </ span >
922
- </ a >
923
-
924
- </ li >
925
-
926
- < li class ="md-nav__item ">
927
- < a href ="#example-3-bestwestern-site-using-datadome-protection " class ="md-nav__link ">
928
- < span class ="md-ellipsis ">
929
- 🔖 Example 3: (BestWestern site using DataDome protection)
930
- </ span >
931
- </ a >
932
-
933
- </ li >
934
-
935
- < li class ="md-nav__item ">
936
- < a href ="#example-4-walmart-site-using-akamai-protection-with-perimeterx " class ="md-nav__link ">
937
- < span class ="md-ellipsis ">
938
- 🔖 Example 4: (Walmart site using Akamai protection with PerimeterX)
939
- </ span >
940
- </ a >
941
-
942
- </ li >
943
-
944
- < li class ="md-nav__item ">
945
- < a href ="#example-5-nike-site-using-shape-security " class ="md-nav__link ">
946
- < span class ="md-ellipsis ">
947
- 🔖 Example 5: (Nike site using Shape Security)
902
+ 🐙 CDP Mode Examples (SeleniumBase/examples/cdp_mode)
948
903
</ span >
949
904
</ a >
950
905
2701
2656
< li class ="md-nav__item ">
2702
2657
< a href ="#cdp-mode-usage " class ="md-nav__link ">
2703
2658
< span class ="md-ellipsis ">
2704
- 🐙 CDP Mode usage
2705
- </ span >
2706
- </ a >
2707
-
2708
- </ li >
2709
-
2710
- < li class ="md-nav__item ">
2711
- < a href ="#here-are-some-common-sbcdp-methods " class ="md-nav__link ">
2712
- < span class ="md-ellipsis ">
2713
- 🐙 Here are some common sb.cdp methods
2714
- </ span >
2715
- </ a >
2716
-
2717
- </ li >
2718
-
2719
- < li class ="md-nav__item ">
2720
- < a href ="#cdp-mode-examples " class ="md-nav__link ">
2721
- < span class ="md-ellipsis ">
2722
- 🐙 CDP Mode examples
2723
- </ span >
2724
- </ a >
2725
-
2726
- </ li >
2727
-
2728
- < li class ="md-nav__item ">
2729
- < a href ="#example-1-pokemon-site-using-incapsulaimperva-protection-with-invisible-recaptcha " class ="md-nav__link ">
2730
- < span class ="md-ellipsis ">
2731
- 🔖 Example 1: (Pokemon site using Incapsula/Imperva protection with invisible reCAPTCHA)
2732
- </ span >
2733
- </ a >
2734
-
2735
- </ li >
2736
-
2737
- < li class ="md-nav__item ">
2738
- < a href ="#example-2-hyatt-site-using-kasada-protection " class ="md-nav__link ">
2739
- < span class ="md-ellipsis ">
2740
- 🔖 Example 2: (Hyatt site using Kasada protection)
2741
- </ span >
2742
- </ a >
2743
-
2744
- </ li >
2745
-
2746
- < li class ="md-nav__item ">
2747
- < a href ="#example-3-bestwestern-site-using-datadome-protection " class ="md-nav__link ">
2748
- < span class ="md-ellipsis ">
2749
- 🔖 Example 3: (BestWestern site using DataDome protection)
2659
+ 🐙 CDP Mode Usage
2750
2660
</ span >
2751
2661
</ a >
2752
2662
2753
2663
</ li >
2754
2664
2755
2665
< li class ="md-nav__item ">
2756
- < a href ="#example-4-walmart-site-using-akamai-protection-with-perimeterx " class ="md-nav__link ">
2666
+ < a href ="#here-are-a-few-common-sbcdp-methods " class ="md-nav__link ">
2757
2667
< span class ="md-ellipsis ">
2758
- 🔖 Example 4: (Walmart site using Akamai protection with PerimeterX)
2668
+ 🐙 Here are a few common sb.cdp methods
2759
2669
</ span >
2760
2670
</ a >
2761
2671
2762
2672
</ li >
2763
2673
2764
2674
< li class ="md-nav__item ">
2765
- < a href ="#example-5-nike-site-using-shape-security " class ="md-nav__link ">
2675
+ < a href ="#cdp-mode-examples-seleniumbaseexamplescdp_mode " class ="md-nav__link ">
2766
2676
< span class ="md-ellipsis ">
2767
- 🔖 Example 5: (Nike site using Shape Security )
2677
+ 🐙 CDP Mode Examples (SeleniumBase/examples/cdp_mode )
2768
2678
</ span >
2769
2679
</ a >
2770
2680
@@ -2826,27 +2736,29 @@ <h2 id="cdp-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img s
2826
2736
< li > Backwards compatibility for existing UC Mode scripts.</ li >
2827
2737
< li > More configuration options when launching browsers.</ li >
2828
2738
< li > More methods. (And bug-fixes for existing methods.)</ li >
2739
+ < li > < code > PyAutoGUI</ code > integration for advanced stealth abilities.</ li >
2829
2740
< li > Faster response time for support. (Eg. < a href ="https://discord.gg/EdhQTn3EyE "> Discord Chat</ a > )</ li >
2830
2741
</ ul >
2831
2742
< hr />
2832
- < h3 id ="cdp-mode-usage "> 🐙 < b translate ="no "> CDP Mode</ b > usage < a class ="headerlink " href ="#cdp-mode-usage " title ="Permanent link "> ¶</ a > </ h3 >
2743
+ < h3 id ="cdp-mode-usage "> 🐙 < b translate ="no "> CDP Mode</ b > Usage < a class ="headerlink " href ="#cdp-mode-usage " title ="Permanent link "> ¶</ a > </ h3 >
2833
2744
< ul >
2834
2745
< li > < strong > < code > sb.activate_cdp_mode(url)</ code > </ strong > </ li >
2835
2746
</ ul >
2836
2747
< blockquote >
2837
2748
< p > (Call that from a < strong > UC Mode</ strong > script)</ p >
2838
2749
</ blockquote >
2839
2750
< p > That disconnects WebDriver from Chrome (which prevents detection), and gives you access to < code > sb.cdp</ code > methods (which don't trigger anti-bot checks).</ p >
2840
- < h3 id ="here-are-some- common-sbcdp-methods "> 🐙 Here are some common < code > sb.cdp</ code > methods< a class ="headerlink " href ="#here-are-some -common-sbcdp-methods " title ="Permanent link "> ¶</ a > </ h3 >
2751
+ < h3 id ="here-are-a-few- common-sbcdp-methods "> 🐙 Here are a few common < code > sb.cdp</ code > methods< a class ="headerlink " href ="#here-are-a-few -common-sbcdp-methods " title ="Permanent link "> ¶</ a > </ h3 >
2841
2752
< ul >
2842
2753
< li > < code > sb.cdp.click(selector)</ code > </ li >
2843
2754
< li > < code > sb.cdp.click_if_visible(selector)</ code > </ li >
2755
+ < li > < code > sb.cdp.gui_click_element(selector)</ code > </ li >
2844
2756
< li > < code > sb.cdp.type(selector, text)</ code > </ li >
2845
2757
< li > < code > sb.cdp.press_keys(selector, text)</ code > </ li >
2846
2758
< li > < code > sb.cdp.select_all(selector)</ code > </ li >
2847
2759
< li > < code > sb.cdp.get_text(selector)</ code > </ li >
2848
2760
</ ul >
2849
- < p > When < code > type()</ code > is too fast, use the slower < code > press_keys()</ code > to avoid detection. You can also use < code > sb.sleep(seconds)</ code > to slow things down.</ p >
2761
+ < p > When < code > type()</ code > is too fast, use the slower < code > press_keys()</ code > to avoid detection. You can also use < code > sb.sleep(seconds)</ code > to slow things down. Methods that start with < code > sb.cdp.gui </ code > use < code > PyAutoGUI </ code > for interaction. </ p >
2850
2762
< p > To use WebDriver methods again, call:</ p >
2851
2763
< ul >
2852
2764
< li > < strong > < code > sb.reconnect()</ code > </ strong > or < strong > < code > sb.connect()</ code > </ strong > </ li >
@@ -2862,17 +2774,12 @@ <h3 id="here-are-some-common-sbcdp-methods">🐙 Here are some common <code>sb.c
2862
2774
< li > < strong > < code > sb.is_connected()</ code > </ strong > </ li >
2863
2775
</ ul >
2864
2776
< hr />
2865
- < h3 id ="cdp-mode-examples "> 🐙 < b translate ="no "> CDP Mode</ b > examples< a class ="headerlink " href ="#cdp-mode-examples " title ="Permanent link "> ¶</ a > </ h3 >
2866
- < blockquote >
2867
- < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode "> SeleniumBase/examples/cdp_mode</ a > </ p >
2868
- </ blockquote >
2869
- < h3 id ="example-1-pokemon-site-using-incapsulaimperva-protection-with-invisible-recaptcha "> 🔖 Example 1: (Pokemon site using Incapsula/Imperva protection with invisible reCAPTCHA)< a class ="headerlink " href ="#example-1-pokemon-site-using-incapsulaimperva-protection-with-invisible-recaptcha " title ="Permanent link "> ¶</ a > </ h3 >
2870
- < blockquote >
2871
- < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_pokemon.py "> SeleniumBase/examples/cdp_mode/raw_pokemon.py</ a > </ p >
2872
- </ blockquote >
2777
+ < h3 id ="cdp-mode-examples-seleniumbaseexamplescdp_mode "> 🐙 < b translate ="no "> CDP Mode</ b > Examples (< a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode "> SeleniumBase/examples/cdp_mode</ a > )< a class ="headerlink " href ="#cdp-mode-examples-seleniumbaseexamplescdp_mode " title ="Permanent link "> ¶</ a > </ h3 >
2778
+ < p > < div /> </ p >
2779
+
2873
2780
< div > </ div >
2874
2781
< details >
2875
- < summary > ▶️ ( < b > Click to expand code preview </ b > ) </ summary >
2782
+ < summary > ▶️ 🔖 < b > Example 1: (Pokemon site using Incapsula/Imperva protection with invisible reCAPTCHA) </ b > </ summary >
2876
2783
2877
2784
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="kn "> from</ span > < span class ="nn "> seleniumbase</ span > < span class ="kn "> import</ span > < span class ="n "> SB</ span >
2878
2785
@@ -2925,13 +2832,12 @@ <h3 id="example-1-pokemon-site-using-incapsulaimperva-protection-with-invisible-
2925
2832
2926
2833
</ details >
2927
2834
2928
- < h3 id ="example-2-hyatt-site-using-kasada-protection "> 🔖 Example 2: (Hyatt site using Kasada protection)< a class ="headerlink " href ="#example-2-hyatt-site-using-kasada-protection " title ="Permanent link "> ¶</ a > </ h3 >
2929
2835
< blockquote >
2930
- < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_hyatt .py "> SeleniumBase/examples/cdp_mode/raw_hyatt .py</ a > </ p >
2836
+ < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_pokemon .py "> SeleniumBase/examples/cdp_mode/raw_pokemon .py</ a > </ p >
2931
2837
</ blockquote >
2932
2838
< div > </ div >
2933
2839
< details >
2934
- < summary > ▶️ ( < b > Click to expand code preview </ b > ) </ summary >
2840
+ < summary > ▶️ 🔖 < b > Example 2: (Hyatt site using Kasada protection) </ b > </ summary >
2935
2841
2936
2842
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="kn "> from</ span > < span class ="nn "> seleniumbase</ span > < span class ="kn "> import</ span > < span class ="n "> SB</ span >
2937
2843
@@ -2971,13 +2877,12 @@ <h3 id="example-2-hyatt-site-using-kasada-protection">🔖 Example 2: (Hyatt sit
2971
2877
2972
2878
</ details >
2973
2879
2974
- < h3 id ="example-3-bestwestern-site-using-datadome-protection "> 🔖 Example 3: (BestWestern site using DataDome protection)< a class ="headerlink " href ="#example-3-bestwestern-site-using-datadome-protection " title ="Permanent link "> ¶</ a > </ h3 >
2975
- < ul >
2976
- < li > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_bestwestern.py "> SeleniumBase/examples/cdp_mode/raw_bestwestern.py</ a > </ li >
2977
- </ ul >
2880
+ < blockquote >
2881
+ < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_hyatt.py "> SeleniumBase/examples/cdp_mode/raw_hyatt.py</ a > </ p >
2882
+ </ blockquote >
2978
2883
< div > </ div >
2979
2884
< details >
2980
- < summary > ▶️ ( < b > Click to expand code preview </ b > ) </ summary >
2885
+ < summary > ▶️ 🔖 < b > Example 3: (BestWestern site using DataDome protection) </ b > </ summary >
2981
2886
2982
2887
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="kn "> from</ span > < span class ="nn "> seleniumbase</ span > < span class ="kn "> import</ span > < span class ="n "> SB</ span >
2983
2888
@@ -3014,13 +2919,12 @@ <h3 id="example-3-bestwestern-site-using-datadome-protection">🔖 Example 3: (B
3014
2919
3015
2920
</ details >
3016
2921
3017
- < h3 id ="example-4-walmart-site-using-akamai-protection-with-perimeterx "> 🔖 Example 4: (Walmart site using Akamai protection with PerimeterX)< a class ="headerlink " href ="#example-4-walmart-site-using-akamai-protection-with-perimeterx " title ="Permanent link "> ¶</ a > </ h3 >
3018
- < ul >
3019
- < li > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_walmart.py "> SeleniumBase/examples/cdp_mode/raw_walmart.py</ a > </ li >
3020
- </ ul >
2922
+ < blockquote >
2923
+ < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_bestwestern.py "> SeleniumBase/examples/cdp_mode/raw_bestwestern.py</ a > </ p >
2924
+ </ blockquote >
3021
2925
< div > </ div >
3022
2926
< details >
3023
- < summary > ▶️ ( < b > Click to expand code preview </ b > ) </ summary >
2927
+ < summary > ▶️ 🔖 < b > Example 4: (Walmart site using Akamai protection with PerimeterX) </ b > </ summary >
3024
2928
3025
2929
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="kn "> from</ span > < span class ="nn "> seleniumbase</ span > < span class ="kn "> import</ span > < span class ="n "> SB</ span >
3026
2930
@@ -3059,13 +2963,12 @@ <h3 id="example-4-walmart-site-using-akamai-protection-with-perimeterx">🔖 Exa
3059
2963
3060
2964
</ details >
3061
2965
3062
- < h3 id ="example-5-nike-site-using-shape-security "> 🔖 Example 5: (Nike site using Shape Security)< a class ="headerlink " href ="#example-5-nike-site-using-shape-security " title ="Permanent link "> ¶</ a > </ h3 >
3063
- < ul >
3064
- < li > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_nike.py "> SeleniumBase/examples/cdp_mode/raw_nike.py</ a > </ li >
3065
- </ ul >
2966
+ < blockquote >
2967
+ < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_walmart.py "> SeleniumBase/examples/cdp_mode/raw_walmart.py</ a > </ p >
2968
+ </ blockquote >
3066
2969
< div > </ div >
3067
2970
< details >
3068
- < summary > ▶️ ( < b > Click to expand code preview </ b > ) </ summary >
2971
+ < summary > ▶️ 🔖 < b > Example 5: (Nike site using Shape Security) </ b > </ summary >
3069
2972
3070
2973
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="kn "> from</ span > < span class ="nn "> seleniumbase</ span > < span class ="kn "> import</ span > < span class ="n "> SB</ span >
3071
2974
@@ -3088,10 +2991,15 @@ <h3 id="example-5-nike-site-using-shape-security">🔖 Example 5: (Nike site usi
3088
2991
3089
2992
</ details >
3090
2993
2994
+ < blockquote >
2995
+ < p > < a href ="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/cdp_mode/raw_nike.py "> SeleniumBase/examples/cdp_mode/raw_nike.py</ a > </ p >
2996
+ </ blockquote >
2997
+ < p > < div /> </ p >
2998
+
3091
2999
< p > (< b > Note:</ b > Extra < code translate ="no "> sb.sleep()</ code > calls have been added to prevent bot-detection because some sites will flag you as a bot if you perform actions too quickly.)</ p >
3092
3000
< p > (< b > Note:</ b > Some sites may IP-block you for 36 hours or more if they catch you using regular < span translate ="no "> Selenium WebDriver</ span > . Be extra careful when creating and/or modifying automation scripts that run on them.)</ p >
3093
3001
< hr />
3094
- < h3 id ="cdp-mode-api-methods "> 🐙 CDP Mode API / Methods< a class ="headerlink " href ="#cdp-mode-api-methods " title ="Permanent link "> ¶</ a > </ h3 >
3002
+ < h3 id ="cdp-mode-api-methods "> 🐙 < b translate =" no " > CDP Mode</ b > API / Methods< a class ="headerlink " href ="#cdp-mode-api-methods " title ="Permanent link "> ¶</ a > </ h3 >
3095
3003
< p > (Some method args have been left out for simplicity. Eg: < code translate ="no "> timeout</ code > )</ p >
3096
3004
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="n "> sb</ span > < span class ="o "> .</ span > < span class ="n "> cdp</ span > < span class ="o "> .</ span > < span class ="n "> get</ span > < span class ="p "> (</ span > < span class ="n "> url</ span > < span class ="p "> )</ span >
3097
3005
< span class ="n "> sb</ span > < span class ="o "> .</ span > < span class ="n "> cdp</ span > < span class ="o "> .</ span > < span class ="n "> open</ span > < span class ="p "> (</ span > < span class ="n "> url</ span > < span class ="p "> )</ span >
@@ -3220,7 +3128,7 @@ <h3 id="cdp-mode-api-methods">🐙 CDP Mode API / Methods<a class="headerlink" h
3220
3128
< span class ="n "> sb</ span > < span class ="o "> .</ span > < span class ="n "> cdp</ span > < span class ="o "> .</ span > < span class ="n "> save_screenshot</ span > < span class ="p "> (</ span > < span class ="n "> name</ span > < span class ="p "> ,</ span > < span class ="n "> folder</ span > < span class ="o "> =</ span > < span class ="kc "> None</ span > < span class ="p "> ,</ span > < span class ="n "> selector</ span > < span class ="o "> =</ span > < span class ="kc "> None</ span > < span class ="p "> )</ span >
3221
3129
</ code > </ pre > </ div >
3222
3130
< hr />
3223
- < h3 id ="cdp-mode-webelement-api-methods "> 🐙 CDP Mode WebElement API / Methods< a class ="headerlink " href ="#cdp-mode-webelement-api-methods " title ="Permanent link "> ¶</ a > </ h3 >
3131
+ < h3 id ="cdp-mode-webelement-api-methods "> 🐙 < b translate =" no " > CDP Mode</ b > WebElement API / Methods< a class ="headerlink " href ="#cdp-mode-webelement-api-methods " title ="Permanent link "> ¶</ a > </ h3 >
3224
3132
< div class ="highlight "> < pre > < span > </ span > < code > < span class ="n "> element</ span > < span class ="o "> .</ span > < span class ="n "> clear_input</ span > < span class ="p "> ()</ span >
3225
3133
< span class ="n "> element</ span > < span class ="o "> .</ span > < span class ="n "> click</ span > < span class ="p "> ()</ span >
3226
3134
< span class ="n "> element</ span > < span class ="o "> .</ span > < span class ="n "> flash</ span > < span class ="p "> (</ span > < span class ="n "> duration</ span > < span class ="o "> =</ span > < span class ="mf "> 0.5</ span > < span class ="p "> ,</ span > < span class ="n "> color</ span > < span class ="o "> =</ span > < span class ="s2 "> "EE4488"</ span > < span class ="p "> )</ span >
0 commit comments