@@ -301,28 +301,7 @@ def select(self, selector, timeout=None):
301301 self .__add_light_pause ()
302302 selector = self .__convert_to_css_if_xpath (selector )
303303 if (":contains(" in selector ):
304- tag_name = selector .split (":contains(" )[0 ].split (" " )[- 1 ]
305- text = selector .split (":contains(" )[1 ].split (")" )[0 ][1 :- 1 ]
306- with suppress (Exception ):
307- new_timeout = timeout
308- if new_timeout < 1 :
309- new_timeout = 1
310- self .loop .run_until_complete (
311- self .page .select (tag_name , timeout = new_timeout )
312- )
313- self .loop .run_until_complete (
314- self .page .find (text , timeout = new_timeout )
315- )
316- elements = self .find_elements_by_text (text , tag_name = tag_name )
317- if not elements :
318- plural = "s"
319- if timeout == 1 :
320- plural = ""
321- msg = "\n Element {%s} was not found after %s second%s!"
322- message = msg % (selector , timeout , plural )
323- raise Exception (message )
324- element = self .__add_sync_methods (elements [0 ])
325- return element
304+ return self .find_element (selector , timeout = timeout )
326305 failure = False
327306 try :
328307 element = self .loop .run_until_complete (
@@ -1708,9 +1687,9 @@ def gui_click_captcha(self):
17081687 selector = '[class*=spacer] + div div'
17091688 elif (
17101689 self .is_element_present ('[name*="cf-turnstile-"]' )
1711- and self .is_element_present ("div .spacer div" )
1690+ and self .is_element_present (".spacer div:not([class]) " )
17121691 ):
1713- selector = "div .spacer div"
1692+ selector = ".spacer div:not([class]) "
17141693 elif (
17151694 self .is_element_present ('script[src*="challenges.c"]' )
17161695 and self .is_element_present (
@@ -1722,6 +1701,8 @@ def gui_click_captcha(self):
17221701 "div#turnstile-widget div:not([class])"
17231702 ):
17241703 selector = "div#turnstile-widget div:not([class])"
1704+ elif self .is_element_present ("ngx-turnstile div:not([class])" ):
1705+ selector = "ngx-turnstile div:not([class])"
17251706 elif self .is_element_present (
17261707 'form div:not([class]):has(input[name*="cf-turn"])'
17271708 ):
@@ -1742,6 +1723,14 @@ def gui_click_captcha(self):
17421723 selector = ".cf-turnstile-wrapper"
17431724 elif self .is_element_present ('[class="cf-turnstile"]' ):
17441725 selector = '[class="cf-turnstile"]'
1726+ elif self .is_element_present (
1727+ '[id*="turnstile"] div:not([class])'
1728+ ):
1729+ selector = '[id*="turnstile"] div:not([class])'
1730+ elif self .is_element_present (
1731+ '[class*="turnstile"] div:not([class])'
1732+ ):
1733+ selector = '[class*="turnstile"] div:not([class])'
17451734 elif self .is_element_present (
17461735 '[data-callback="onCaptchaSuccess"]'
17471736 ):
@@ -1793,21 +1782,45 @@ def gui_click_captcha(self):
17931782 self .loop .run_until_complete (self .page .evaluate (script ))
17941783 self .loop .run_until_complete (self .page .wait ())
17951784 elif (
1796- self .is_element_present ("form" )
1797- and self .is_element_present (
1798- 'form [id*="turnstile"] > div:not([class])'
1785+ self .is_element_present (
1786+ 'form [id*="turnstile"] div:not([class])'
1787+ )
1788+ or self .is_element_present (
1789+ 'form [class*="turnstile"] div:not([class])'
17991790 )
18001791 ):
18011792 script = (
18021793 """var $elements = document.querySelectorAll(
18031794 'form [id*="turnstile"]');
18041795 var index = 0, length = $elements.length;
18051796 for(; index < length; index++){
1797+ $elements[index].setAttribute('align', 'left');}
1798+ var $elements = document.querySelectorAll(
1799+ 'form [class*="turnstile"]');
1800+ var index = 0, length = $elements.length;
1801+ for(; index < length; index++){
18061802 $elements[index].setAttribute('align', 'left');}"""
18071803 )
18081804 with suppress (Exception ):
18091805 self .loop .run_until_complete (self .page .evaluate (script ))
18101806 self .loop .run_until_complete (self .page .wait ())
1807+ elif (
1808+ self .is_element_present (
1809+ '[style*="text-align: center;"] div:not([class])'
1810+ )
1811+ ):
1812+ script = (
1813+ """var $elements = document.querySelectorAll(
1814+ '[style*="text-align: center;"]');
1815+ var index = 0, length = $elements.length;
1816+ for(; index < length; index++){
1817+ the_style = $elements[index].getAttribute('style');
1818+ new_style = the_style.replaceAll('center', 'left');
1819+ $elements[index].setAttribute('style', new_style);}"""
1820+ )
1821+ with suppress (Exception ):
1822+ self .loop .run_until_complete (self .page .evaluate (script ))
1823+ self .loop .run_until_complete (self .page .wait ())
18111824 with suppress (Exception ):
18121825 time .sleep (0.08 )
18131826 element_rect = self .get_gui_element_rect (selector , timeout = 1 )
@@ -2163,6 +2176,10 @@ def wait_for_element_visible(self, selector, timeout=None):
21632176 time .sleep (0.1 )
21642177 raise Exception ("Element {%s} was not visible!" % selector )
21652178
2179+ def wait_for_element (self , selector , ** kwargs ):
2180+ """Same as wait_for_element_visible()"""
2181+ return self .wait_for_element_visible (selector , ** kwargs )
2182+
21662183 def wait_for_element_not_visible (self , selector , timeout = None ):
21672184 """Wait for element to not be visible on page. (May still be in DOM)"""
21682185 if not timeout :
0 commit comments