我必须根据运行脚本的浏览器来更改变量的值。我的代码如下:
*** Variables ***
${upload_file} xpath=//*[@id="file"]
${path_jpg} ${EXECDIR}\\test_data\\Browse_Image\\apple.jpg
${path_png} ${EXECDIR}\\test_data\\Browse_Image\\apple.png
${path_gif} ${EXECDIR}\\test_data\\Browse_Image\\apple.gif
${path_webm} ${EXECDIR}\\test_data\\Browse_Image\\apple.ppt
${browse_remove_edge} xpath=/html/body/app-root/div/div/div/project-creation/div[2]/div[2]/div[3]/div[2]/a
*** Keywords ***
Upload a .jpg image
load "${path_jpg}" into "${upload_file}"
Upload a .png image
load "${path_png}" into "${upload_file}"
Upload project image (unsupported format)
load "${path_webm}" into "${upload_file}"
Upload a .gif image
load "${path_gif}" into "${upload_file}"
在上面的代码中,如果我的浏览器是Edge,则脚本必须使用变量$ {browse_remove_edge}而不是$ {upload_file} 而且我还在变量“ $ {browser}”中声明了我的浏览器,如下所示:
${browser} chrome