gpt4 book ai didi

python - 构建函数以清除字段和 send_keys

转载 作者:行者123 更新时间:2023-12-01 03:31:38 27 4
gpt4 key购买 nike

我正在尝试构建一个函数来清除字段和 send_keys,但出现错误。看我的代码:

base.py

class Page(object):

def clear_sendkeys(self, *locator, text):

self.driver.find_element(*locator).clear()
self.driver.find_element(*locator).send_keys(text)

contractors_page.py

from selenium import webdriver
from base import Page
from locators import *
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select
from faker import Faker
import os
import time

def update_contacts_form(self):

enter_building = fake.building_number()

self.clear_sendkeys(*ContractorsLocators.EMAIL, enter_building)

我的错误

E self.clear_sendkeys(*ContractorsLocators.EMAIL, enter_building) E SyntaxError: only named arguments may follow *expression

最佳答案

变量参数之后不能有固定参数,这意味着defclear_sendkeys(self, *locator, text) 是错误的,应该是defclear_sendkeys(self, text, *locator)

关于python - 构建函数以清除字段和 send_keys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40898856/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com