鼠标滚轮向下滑动, pyautogui.scroll(-400)
结合,鼠标悬停使用ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH, ‘//Pane/Document/ComboBox’)).perform()
可以先悬停, 然后向下滑动
@pytest.mark.run(order=500002)
@allure.title("变更默认消息快捷键")
@pytest.mark.parametrize("条件", ["PC自动化测试群聊消息"])
def test_变更默认消息快捷键(self, 条件):
try:
# 点击头像
self.driver.find_element(By.XPATH, '//Pane[@Name="Hwork"]/Document[@Name="Hwork"]/Image').click()
self.driver.find_element(By.XPATH,
'//Pane[@Name="Hwork"]/Document[@Name="Hwork"]/ToolTip/Text[@Name="设置"]').click()
ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH,
'//Pane[@Name="Hwork"]/Document[@Name="Hwork"]/ComboBox')).perform()
pyautogui.scroll(-400)
time.sleep(1)
pyautogui.scroll(-400)
time.sleep(1)
ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH,
'//Pane[@Name="Hwork"]/Document[@Name="Hwork"]/ComboBox[3]')).click().perform()
self.driver.find_element(By.XPATH,'//Pane[@Name="Hwork"]/Document[@Name="Hwork"]/Text[@Name="Alt+Enter"]').click()
time.sleep(1)
# 换个 群,单聊拉群1
self.driver.find_element(by=By.NAME, value="搜索").click()
time.sleep(1)
self.driver.find_element(by=By.NAME, value="搜索").send_keys(条件)
time.sleep(1)
self.driver.find_element(by=By.NAME, value=条件).click()
time.sleep(1)
# 在,,切换输入法, 切换为英文输入法
shift_en(self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text'))
# 光标输入框
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').click()
# 判断切换成功 ,Alt+Enter,Enter
assert self.driver.find_element(By.XPATH, '//Button[@Name="发送"]/following-sibling::Text').text == "Alt + Enter 键 发送,Enter 键 换行"
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').send_keys("Alt + Enter 键 发送,Enter 键 换行")
# 点击发送
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Button[@Name="发送"]').click()
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').send_keys("Enter 键 换行")
# 换行
pyautogui.press('enter')
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').send_keys(
"---我是Enter换行后文本---")
pyautogui.press('enter')
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').send_keys(
"[赞]")
pyautogui.press('enter')
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').send_keys(
"@#$%^*!-_+=~ 我是特殊符号~~~&")
pyautogui.press('enter')
self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Group/Text').send_keys(
"---我是Enter换行后文本---")
time.sleep(1)
ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Button[@Name="发送"]')).click().perform()
assert self.driver.find_element(By.XPATH, '//Document[@Name="hwork-desktop-im"]/Text[@Name="我是特殊符号~~~&"]').text == "我是特殊符号~~~&"
finally:
pyautogui.hotkey('ctrl', 'a')
pyautogui.press('delete')
self.driver.close()