在以下代码中:-
- 我正在从搜索字段中删除文本
- 然后在搜索字段中添加新订单号
- 按Enter开始搜索
前两个步骤发生得很好,但当触发enter按钮代码时,它会在搜索字段中键入323(按订单号追加),而不执行任何操作。我也试过很多其他键,但它们都是数字键,没有键功能可以通过send_键工作。文章源自玩技e族-https://www.playezu.com/183003.html
以下是上述要求的代码:-文章源自玩技e族-https://www.playezu.com/183003.html
import pytest
from curses import KEY_ENTER
from locale import normalize
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class TestFunc:
order =""
def test_validate_offer(self):
username = "******"
password = "*****"
url = "http://*****"
svc = Service("C:\bin\geckodriver.exe")
driver = webdriver.Firefox(service=svc)
pytest.order='3446'
driver.implicitly_wait(15)
driver.get("url")
driver.find_element(By.ID,"login").send_keys(username)
driver.find_element(By.ID,"password").send_keys(password)
driver.find_element(By.XPATH,"//button[@type='submit']").click()
driver.find_element(By.XPATH,"//div[@class='mk_apps_sidebar_panel']//li[2]//a[1]").click()
driver.find_element(By.XPATH,"//i[@title='Remove']").click()
driver.find_element(By.XPATH,"//input[@placeholder='Search...']").send_keys(pytest.order)
wait = WebDriverWait(driver,10)
search=wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "o_searchview_input")))
**-->** search.send_keys(KEY_ENTER)
sale_element=driver.find_element(By.XPATH,"//input[@placeholder='pytest.order']")
sleep(5)
assert sale_element.text == pytest.order
driver.close()
感谢您的帮助。文章源自玩技e族-https://www.playezu.com/183003.html
软件项目功能测试报告文章源自玩技e族-https://www.playezu.com/183003.html 文章源自玩技e族-https://www.playezu.com/183003.html
评论