Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何实现右键点击 #16

Open
lzx20121123 opened this issue Sep 4, 2020 · 1 comment
Open

请问如何实现右键点击 #16

lzx20121123 opened this issue Sep 4, 2020 · 1 comment

Comments

@lzx20121123
Copy link

import os,pytest,sys,random,string
from os.path import abspath, dirname
from time import sleep
base_path = dirname(dirname(abspath(file)))
sys.path.insert(0, base_path)
from config import RunConfig
from util.read_data import ReadData
from common.common_module import CommonKey
from page.element_page import ElementPage
from poium import PageWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver

def test_add_object_succ(browser,base_url):
'''
删除对象
'''
dr=CommonKey().Plan_creat_Information_system_check(browser,base_url) #登录返回dr
dr.add_object_button.click()
dr.object_type.click()
dr.object_server.click()
dr.object_IP.send_keys('192.168.30.80')
dr.database_or_system.click()
dr.system_win.click()
sleep(0.5)
dr.button_save.click()
sleep(0.5)
dr.button_quit.click()
right_win=dr.right_windows
ActionChains(dr).move_to_element(right_win).context_click()
dr.del_object.click()
dr.determine_button2.click()
PageWait(dr.Tips)
sleep(0.5)
assert dr.Tips.text=='操作成功!'

想通过以上代码实现右键点击,导入了 ActionChains,在执行过程中出现下面报错
image
网上对于这方面资料不多,没找到这方面的资料,自己代码功底也不够深
期待您的解答,非常感谢

@lzx20121123
Copy link
Author

已经解决了,看了下源码,有这个功能
ActionChains(dr).move_to_element(right_win).context_click()改成 dr.context_click(dr.right_windows)即可
不需要 引入ActionChains了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant