github seleniumbase/SeleniumBase v1.47.4
Make improvements to smart-word-wrap

latest releases: v4.27.0, v4.26.4, v4.26.3...
3 years ago

Make improvements to smart-word-wrap

  • SeleniumBase smart-word-wrap is used when displaying code to the console when using the sbase print or sbase translate commands. In the case that the console is not wide enough to display an entire line of code, the code will be wrapped in such a way that Python syntax rules are not broken. This is different from a standard word wrap where code will begin at the very start of the next line, rather than following Python indentation rules.

  • Here's an example of smart-word-wrap on a narrow console screen:

$ sbase print basic_test.py -n
-------------------------------------------
   1 from seleniumbase import BaseCase     
   2                                       
   3                                       
   4 class MyTestClass(BaseCase):          
   5                                       
   6     def test_basic(self):             
   7         self.open(                    
   8             "https://"                
   9             "store.xkcd.com/search")  
  10         self.type(                    
  11             'input[name="q"]',        
  12             "xkcd book\n")            
  13         self.assert_text(             
  14             "xkcd book",              
  15             "div.results")            
  16         self.open(                    
  17             "https://xkcd.com/353/")  
  18         self.click('a[rel="license"]')
  19         self.go_back()                
  20         self.click_link_text("About") 
  21         self.click_link_text(         
  22             "comic #249")             
  23         self.assert_element(          
  24             'img[alt*="Chess"]')      
-------------------------------------------
  • Here's how that same test looks when printing to a wide console screen:
$ sbase print basic_test.py -n
-----------------------------------------------------------
   1 from seleniumbase import BaseCase                     
   2                                                       
   3                                                       
   4 class MyTestClass(BaseCase):                          
   5                                                       
   6     def test_basic(self):                             
   7         self.open("https://store.xkcd.com/search")    
   8         self.type('input[name="q"]', "xkcd book\n")   
   9         self.assert_text("xkcd book", "div.results")  
  10         self.open("https://xkcd.com/353/")            
  11         self.click('a[rel="license"]')                
  12         self.go_back()                                
  13         self.click_link_text("About")                 
  14         self.click_link_text("comic #249")            
  15         self.assert_element('img[alt*="Chess"]')      
-----------------------------------------------------------
  • SeleniumBase smart-word-wrap also works with sbase translate:
$ sbase translate basic_test.py --ja -p -n

 basic_test.py was translated to Japanese! (Previous: English)

  ***  Here are the results:  >>> 
-------------------------------------------------
   1 from seleniumbase.translate.japanese \      
   2     import セレニウムテストケース           
   3                                             
   4                                             
   5 class MyTestClass(セレニウムテストケース):  
   6                                             
   7     def test_basic(self):                   
   8         self.を開く(                        
   9             "https://store.xkcd.com/search")
  10         self.入力(                          
  11             'input[name="q"]',              
  12             "xkcd book\n")                  
  13         self.テキストを確認する(            
  14             "xkcd book", "div.results")     
  15         self.を開く("https://xkcd.com/353/")
  16         self.クリックして(                  
  17             'a[rel="license"]')             
  18         self.戻る()                         
  19         self.リンクテキストをクリックします(
  20             "About")                        
  21         self.リンクテキストをクリックします(
  22             "comic #249")                   
  23         self.要素を確認する(                
  24             'img[alt*="Chess"]')            
-------------------------------------------------
  • Here's how that same translation looks on a wide screen:
$ sbase translate basic_test.py --ja -p -n

 basic_test.py was translated to Japanese! (Previous: English)

  ***  Here are the results:  >>> 
-------------------------------------------------------------------------
   1 from seleniumbase.translate.japanese import セレニウムテストケース  
   2                                                                     
   3                                                                     
   4 class MyTestClass(セレニウムテストケース):                          
   5                                                                     
   6     def test_basic(self):                                           
   7         self.を開く("https://store.xkcd.com/search")                
   8         self.入力('input[name="q"]', "xkcd book\n")                 
   9         self.テキストを確認する("xkcd book", "div.results")         
  10         self.を開く("https://xkcd.com/353/")                        
  11         self.クリックして('a[rel="license"]')                       
  12         self.戻る()                                                 
  13         self.リンクテキストをクリックします("About")                
  14         self.リンクテキストをクリックします("comic #249")           
  15         self.要素を確認する('img[alt*="Chess"]')                    
-------------------------------------------------------------------------

(Smart-word-wrap only effects console printing. It has no effect on the test itself.)

Don't miss a new SeleniumBase release

NewReleases is sending notifications on new releases.