[英]passing parameter to webdriver instead of driver
我试图从Excel工作表导入数据并将其作为参数传递给python脚本,我也试图将“浏览器”也作为excel文件中的参数。 以下是详细信息。
浏览器在excel表的“B2”单元格中指定:
工作簿名称:Data.xlsx
工作表名称:配置
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import alert_is_present
import openpyxl
wb=openpyxl.load_workbook('Data.xlsx')
config=wb.get_sheet_by_name('Configuration')
'''b1=config["B2"].value'''
url=config["B3"].value
uid=config['B4'].value
pwd=config['B5'].value
Browser=webdriver.config['B2'].value()
'''in the above deceleration I am trying to pass the value from excel sheet, instead of writing the value directly. So from next time on wards, I can update in excel sheet with the required browser'''
class Actions():
def OpenApplication():
Browser.get(url)
我认为这是因为创建webdriver需要更接近,但是你试图将一个字符串放在webdriver
的末尾而没有更近(更接近括号“()”的结尾)。 尝试使用这个if
语句。
wb=openpyxl.load_workbook('Data.xlsx')
config=wb.get_sheet_by_name('Configuration')
b1=config["B2"].value
if b1 == 'Chrome':
Browser = webdriver.Chrome()
elif b1 == 'Firefox':
Browser = webdriver.Firefox()
elif b1 == 'IE':
Browser = webdriver.Ie()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.