Notes robot framework (II): starting from the definition of the parameters in the RF chrome

(A) in the RF custom chrome startup parameters

Here it is to achieve the following 2 functions

1, disable the chrome being prompted by the software-controlled automatic test

2, set the default download path (some of Export, download class features, download the file to the specified path)

A custom keyword

from selenium.webdriver.chrome.options Import the Options 

class   MyKeyword (): 

    DEF   get_chrome_options (Self, downloads_path):
         '' ' 
        custom chrome startup parameters 
        : param downloads_path: Set default file download path 
        : return: 
        ' '' 
        chrome_options = the Options () 
        Prefs = {
             " download.default_directory " : STR (downloads_path), 
        } 
        chrome_options.add_experimental_option ( ' Prefs ' , Prefs) # set the default file download path
        chrome_options.add_argument ( ' disable-infobars ' )      # chrome76 disable the automatic software controlled chrome by 
        # below 2 and above line chrome76 automatically disabled by software control chrome 
        chrome_options.add_experimental_option ( " useAutomationExtension " , False) 
        chrome_options.add_experimental_option ( " excludeSwitches " , [ " enable-Automation " ])
         return chrome_options

In RF reference to this custom keywords logged in, if not able to find the time to perform keyword GET CHROME the OPTIONS , add an environment variable PYTHONPATH, value is the path of the python project.

 

Settings *** *** 
Library SeleniumLibrary 
Library mykeyword.mykeyword.MyKeyword 
Suite Teardown CLOSE BROWSER

 *** *** the Variables 
$ {} Chrome Browser 
$ {} LOGIN_URL HTTPS: //account.cnblogs.com/ signin


 *** the Test Cases *** 
Login - XXXXXX 
    Log - open the browser and enter the login page


 *** Keywords *** 
Log - open the browser and enter the login page 
    $ {Options} = GET CHROME the OPTIONS D: / ProjectName / the Testdata / Downloads 
    the CREATE WebDriver Browser chrome_options} {$ = $ {} Options 
    the GO LOGIN_URL the TO $ {} 
    the SET SELENIUM an IMPLICIT the WAIT  10
    MAXIMIZE BROWSER WINDOW

 

The overall directory structure is as follows:

(B) if you want to use selenium grid in the actual project

   To use the actual project selenium gird, modifications may be slightly on the basis of the above. Here it must be modified on the basis of inherited SeleniumLibrary library, I would next explain it.

(C) python of pythonpath

Finally, a brief description under, python concept of search paths, if prompted no keyword, and you actually wrote this keyword, it may not be python library search path inside.

By import sys sys, path you can see what your search path.

Not to create a new environment variable name, then: Path project: PYTHONPATH value. After adding environment variables, reboot under IDE on the line.

Guess you like

Origin www.cnblogs.com/simple-free/p/12061762.html