How to use click_button method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

test_04_tool.py

Source:test_04_tool.py Github

copy

Full Screen

...18 self.assertTrue(d)19 # 判断数据加载20 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 10))21 # 点击到工具页22 self.b.click_button('xpath', '//*[@text="工具"]')23 # 页面呈现,24 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tool_header_progress"]', 10))25 self.b.close_app()26 def test_b_tool_lock(self):27 "锁屏功能"28 d = self.b.find_element('xpath', '//*[@text="热门"]', 5)29 self.assertTrue(d)30 # 判断数据加载31 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 10))32 # 点击到工具页33 self.b.click_button('xpath', '//*[@text="工具"]')34 # 页面呈现,35 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tool_first_line"]', 10))36 self.b.click_button('xpath','//*[@text="锁屏功能"]')37 sleep(2)38 #锁屏功能页面39 self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/setting_msg_layout"]',10))40 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_music_layout"]',10))41 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_toolbox_layout"]',10))42 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_weather_item"]',10))43 self.assertTrue(44 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_music_check"]', 10))45 # self.b.swipe_up(1)46 d=self.b.find_element('xpath','//*[@text="延迟锁屏"]',10)47 self.assertTrue(d)48 self.b.close_app()49 @AppiumSetup.add50 def test_c_tool_applock(self):51 "应用锁功能校验"52 d = self.b.find_element('xpath', '//*[@text="热门"]', 10)53 self.assertTrue(d)54 # 判断数据加载55 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 10))56 # 点击到工具页57 self.b.click_button('xpath', '//*[@text="工具"]')58 # 页面呈现,59 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tool_first_line"]', 10))60 self.b.click_button('xpath','//*[@text="应用锁"]')61# 查看应用锁默认页面62 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/l_app_select_count"]', 10))63 self.assertTrue(64 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/app_selected"]', 10))65 self.assertTrue(66 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/app_hot"]', 10))67 self.assertTrue(68 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/app_sort_desc"]', 10))69# 点击下一步70 self.b.click_button('xpath','//*[@text="下一步"]')71 # 设置密码页查看72 self.assertTrue(73 self.b.find_element('xpath', '//*[@text="使用数字密码"]', 10))74 self.b.click_button('xpath','//*[@text="使用数字密码"]')75 self.assertTrue(76 self.b.find_element('xpath', '//*[@text="设置密码位数"]', 10))77# 点击下一步78 self.b.click_button('xpath', '//*[@text="下一步>"]')79# 密码设置com.vlocker.locker:id/locknum80 d = self.driver.find_element_by_id("com.vlocker.locker:id/locknum")81 e = d.find_elements_by_id("android.widget.TextView")82 sleep(3)83 self.b.click_button('xpath', '//*[@text="1"]')84 self.b.click_button('xpath', '//*[@text="2"]')85 self.b.click_button('xpath', '//*[@text="3"]')86 self.b.click_button('xpath', '//*[@text="4"]')87# 再次输入88 self.assertTrue(89 self.b.find_element('xpath', '//*[@text="请重复密码"]', 10))90 self.b.click_button('xpath', '//*[@text="1"]')91 self.b.click_button('xpath', '//*[@text="2"]')92 self.b.click_button('xpath', '//*[@text="3"]')93 self.b.click_button('xpath', '//*[@text="4"]')94 sleep(2)95 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')96 # sleep(2)97 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')98# 到密码保护页,只有首次安装app之后才会有密保输入99 self.assertTrue(100 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_question"]', 10))101 self.b.click_button('xpath', '//*[@text="生日是?"]')102 sleep(3)103 # c = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]', 10)104 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')105 # self.assertTrue(c)106 # c.click()107 os.system('adb shell input tap 228 1887')108 sleep(2)109 self.assertTrue(110 self.b.find_element('xpath', '//*[@text="应用锁"]', 10))111 sleep(2)112 self.b.click_button('xpath', '//*[@text="应用锁"]')113 self.b.click_button('xpath', '//*[@text="1"]')114 self.b.click_button('xpath', '//*[@text="2"]')115 self.b.click_button('xpath', '//*[@text="3"]')116 self.b.click_button('xpath', '//*[@text="4"]')117 self.assertTrue(118 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_enable_applock_img"]', 10))119 # 返回桌面点击图库120 # self.driver.keyevent(3)121 # sleep(3)122 # # 启动相册查看123 # cmd = "adb shell am start -W -n com.vivo.gallery/com.android.gallery3d.vivo.GalleryTabActivity "124 # self.content = os.popen(cmd)125 # sleep(2)126 # # 校验应用锁设置生效127 # self.assertTrue(128 # self.b.find_element('xpath', '//*[@text="输入密码"]', 10))129 self.b.close_app()130 def test_d_restartlock(self):131 "重启锁屏"132 d = self.b.find_element('xpath', '//*[@text="热门"]', 10)133 self.assertTrue(d)134 self.b.click_button('xpath', '//*[@text="我的"]')135 d = self.b.find_element('xpath', '//*[@text="设置"]', 10)136 d.click()137 # 关闭锁屏开关138 d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/close_lock_check"]', 10)139 d.click()140 # 点击开启锁屏141 d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/start_lock"]', 10)142 d.click()143 self.b.close_app()144 @AppiumSetup.add145 def test_e_lockpassword(self):146 "锁屏密码设置应用"147 d = self.b.find_element('xpath', '//*[@text="热门"]', 10)148 self.assertTrue(d)149 # 判断数据加载150 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 10))151 # 点击到工具页152 self.b.click_button('xpath', '//*[@text="工具"]')153 # 点击锁屏密码154 self.b.click_button('xpath', '//*[@text="锁屏密码"]')155 d = self.b.find_element('xpath', '//*[@text="密码设置"]', 5)156 self.assertTrue(d)157 # 点击设置数字密码158 d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_enable_num_locker_img"]', 10)159 d.click()160 sleep(2)161 # 下一步162 d = self.b.find_element('xpath', '//*[@text="下一步>"]', 10)163 d.click()164 d = self.b.find_element('xpath', '//*[@text="4位密码"]', 5)165 self.assertTrue(d)166 sleep(3)167 self.b.click_button('xpath', '//*[@text="1"]')168 self.b.click_button('xpath', '//*[@text="2"]')169 self.b.click_button('xpath', '//*[@text="3"]')170 self.b.click_button('xpath', '//*[@text="4"]')171 # 再次输入172 self.assertTrue(173 self.b.find_element('xpath', '//*[@text="请重复密码"]', 10))174 self.b.click_button('xpath', '//*[@text="1"]')175 self.b.click_button('xpath', '//*[@text="2"]')176 self.b.click_button('xpath', '//*[@text="3"]')177 self.b.click_button('xpath', '//*[@text="4"]')178 # sleep(2)179 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_question"]')180 # sleep(2)181 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')182 # # 查看密码类型183 # d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tool_bar_title"]', 10)184 # self.assertTrue(d)185 sleep(2)186 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')187 # sleep(2)188 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')189 # 到密码保护页,只有首次安装app之后才会有密保输入190 self.assertTrue(191 self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_question"]', 10))192 self.b.click_button('xpath', '//*[@text="生日是?"]')193 sleep(3)194 # c = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]', 10)195 # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')196 # self.assertTrue(c)197 # c.click()198 os.system('adb shell input tap 228 1887')199 sleep(2)200 # 灭屏亮屏查看锁屏应用201 self.driver.lock(1)202 # self.driver.unlock()203 # 点亮屏幕204 cmd = 'adb shell input keyevent 26'205 os.popen(cmd)206 sleep(2)207 # 右滑解锁208 self.b.swipe_right(1)209 sleep(2)210 # 当前密码锁屏页校验211 d = self.b.find_element('xpath', '//*[@text="输入密码"]', 5)212 self.assertTrue(d)213 d = self.b.find_element('xpath', '//*[@text="美化密码"]', 5)214 self.assertTrue(d)215 self.b.close_app()216 @AppiumSetup.add217 def test_f_unlocknum(self):218 "解锁数字密码锁屏"219 d = self.b.find_element('xpath', '//*[@text="热门"]', 5)220 self.assertTrue(d)221 # 判断数据加载222 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 10))223 # 灭屏亮屏查看锁屏应用224 self.driver.lock(1)225 # self.driver.unlock()226 cmd = 'adb shell input keyevent 26'227 os.popen(cmd)228 sleep(3)229 # 右滑解锁230 self.b.swipe_right(1)231 sleep(2)232 d = self.b.find_element('xpath', '//*[@text="美化密码"]', 5)233 self.assertTrue(d)234 # 解锁235 self.b.click_button('xpath', '//*[@text="1"]')236 self.b.click_button('xpath', '//*[@text="2"]')237 self.b.click_button('xpath', '//*[@text="3"]')238 self.b.click_button('xpath', '//*[@text="4"]')239 d = self.b.find_element('xpath', '//*[@text="互动主题"]', 5)240 self.assertTrue(d)241 self.b.close_app()242 @AppiumSetup.add243 def test_g_change_nopassword(self):244 " 密码切换无密码锁屏 "245 d = self.b.find_element('xpath', '//*[@text="热门"]', 5)246 self.assertTrue(d)247 # 判断数据加载248 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 10))249 # 点击工具250 self.b.click_button('xpath', '//*[@text="工具"]')251 # 页面呈现,252 self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tool_first_line"]', 10))253 # 锁屏密码页254 sleep(3)255 self.b.click_button('xpath', '//*[@text="锁屏密码"]')256 # 输入原密码257 self.assertTrue(self.b.find_element('xpath', '//*[@text="输入原密码"]', 10))258 sleep(2)259 self.b.click_button('xpath', '//*[@text="1"]')260 self.b.click_button('xpath', '//*[@text="2"]')261 self.b.click_button('xpath', '//*[@text="3"]')262 self.b.click_button('xpath', '//*[@text="4"]')263 # 到密码设置页选择无密码264 self.assertTrue(self.b.find_element('xpath', '//*[@text="密码设置"]', 10))265 # 点击无密码266 self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/setting_none_layout"]')267 # 校验是否已经切换到无密码268 a=self.b.isElement('text','个性设置')269 self.assertTrue(a)270 self.b.close_app()271 def tearDown(self):272 AppiumSetup.tearDownClass()273if __name__ == "__main__":274 unittest.main(verbosity=2)275 suite = unittest.TestSuite()276 suite.addTest(ToolTest("test_g_change_nopassword"))...

Full Screen

Full Screen

common_drivers.py

Source:common_drivers.py Github

copy

Full Screen

...19 :return:20 """21 self.open_windows(url=url)22 if login_position: # 有些页面要切换到指定地方,才能进行登陆23 self.click_button(locator=login_position)24 self.send_keys(locator=username['locator'], value=username['value'])25 self.send_keys(locator=password['locator'], value=password['value'])26 self.click_button(login_button)27 def chaxun_interdace(self,chacun_button,chacun_button1,chacun_button2,28 # chacun_button3,29 guke={}):30 # 先登录31 # a=LoginPage()32 # self.open_windows(url= 'http://47.111.8.42:8080/mms/mms/index.html')33 # self.send_keys(locator=(a.USERNAME_INPUT),value="admir")34 # self.send_keys(locator=(a.PASSWORD_INPUT),value="1234")35 # self.click_button(a.LOGIN_BUTTON)36 # 点击信息查询37 self.click_button(chacun_button)38 # 查询顾客信息39 # 查询40 self.click_button(chacun_button1)41 # 输入顾客编号42 self.send_keys(locator=guke["locator"],value=guke["value"])43 # 点击查询44 self.click_button(chacun_button2)45 # assert "1001239" in browser.get_current_page_source()46 # self.click_button(chacun_button3)47 self.refresh()48 def chaxun_interdace_pope(self,chacun_button,chacun_button1,chacun_button2,chacun_button3,guke={}):49 # 先登录50 # a=LoginPage()51 # self.open_windows(url= 'http://47.111.8.42:8080/mms/mms/index.html')52 # self.send_keys(locator=(a.USERNAME_INPUT),value="admir")53 # self.send_keys(locator=(a.PASSWORD_INPUT),value="1234")54 # self.click_button(a.LOGIN_BUTTON)55 # 点击信息查询56 self.click_button(chacun_button)57 # 查询经办人信息58 self.click_button(chacun_button1)59 # 输入经办人编号60 self.send_keys(locator=guke["locator"],value=guke["value"])61 # 点击查询62 self.click_button(chacun_button2)63 self.click_button(chacun_button3)64 self.refresh()65 def chaxun_interdace_yaop(self,chacun_button,chacun_button1,chacun_button2,guke={}):66 # 先登录67 # a=LoginPage()68 # self.open_windows(url= 'http://47.111.8.42:8080/mms/mms/index.html')69 # self.send_keys(locator=(a.USERNAME_INPUT),value="admir")70 # self.send_keys(locator=(a.PASSWORD_INPUT),value="1234")71 # self.click_button(a.LOGIN_BUTTON)72 # 点击信息查询73 self.click_button(chacun_button)74 # 查询药品人信息75 self.click_button(chacun_button1)76 # 输入药品编号77 self.send_keys(locator=guke["locator"],value=guke["value"])78 # 点击查询79 self.click_button(chacun_button2)80 self.refresh()81 def luru_guke_interdace(self,chacun_button778,chacun_button1,82 chacun_button2,ida={},name={},age={},tele={},poper={},83 time={},med={},address={},dale={},bei={}84 ):85 # 先登录86 # a = LoginPage()87 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')88 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")89 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")90 # self.click_button(a.LOGIN_BUTTON)91 # 点击信息录入92 self.click_button(chacun_button778)93 # 点击录入顾客信息94 self.click_button(chacun_button1)95 # 输入编号96 self.send_keys(locator=ida["locator"], value=ida["value"])97 # 输入name98 self.send_keys(locator=name["locator"], value=name["value"])99 # 输入age100 self.send_keys(locator=age["locator"], value=age["value"])101 # 输入电话102 self.send_keys(locator=tele["locator"], value=tele["value"])103 # 输入经办人104 self.send_keys(locator=poper["locator"], value=poper["value"])105 # 日期106 self.send_keys(locator=time["locator"], value=time["value"])107 # 药品108 self.send_keys(locator=med["locator"], value=med["value"])109 # 住址110 self.send_keys(locator=address["locator"], value=address["value"])111 # 症状112 self.send_keys(locator=dale["locator"], value=dale["value"])113 # 备注114 self.send_keys(locator=bei["locator"], value=bei["value"])115 # 点击录入116 self.click_button(chacun_button2)117 self.refresh()118 def luru_pope(self,can,can1,can2,can3,ida={},name={},tele={},bz={}):119 # a = LoginPage()120 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')121 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")122 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")123 # self.click_button(a.LOGIN_BUTTON)124 # 点击信息录入125 self.click_button(can)126 # 点击录入经办人127 self.click_button(can1)128 # 编号129 self.send_keys(locator=ida["locator"], value=ida["value"])130 # 姓名131 self.send_keys(locator=name["locator"], value=name["value"])132 # 电话133 self.send_keys(locator=tele["locator"], value=tele["value"])134 # 备注135 self.send_keys(locator=bz["locator"], value=bz["value"])136 self.click_button(can2)137 self.click_button(can3)138 self.refresh()139 def luru_yaop(self,can,can1,can2,can3,ida={},name={},bz={}):140 # a = LoginPage()141 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')142 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")143 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")144 # self.click_button(a.LOGIN_BUTTON)145 # 点击信息录入146 self.click_button(can)147 # 点击录入药品148 self.click_button(can1)149 # 编号150 self.send_keys(locator=ida["locator"], value=ida["value"])151 # 名称152 self.send_keys(locator=name["locator"], value=name["value"])153 # 功效154 self.send_keys(locator=bz["locator"], value=bz["value"])155 # 点击录入156 self.click_button(can2)157 # 点击确定158 self.click_button(can3)159 self.refresh()160 def shanchu_interdace(self,can1,can2,can3,can4,can5):161 # a = LoginPage()162 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')163 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")164 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")165 # self.click_button(a.LOGIN_BUTTON)166 # 信息删除167 self.click_button(can1)168 # 顾客删除169 self.click_button(can2)170 # 选择guke171 self.click_button(can3)172 # 点击产删除173 self.click_button(can4)174 # 点击确定175 self.click_button(can5)176 self.refresh()177 def shanchu_yaop_pope(self,can,can1,can2,can3,can4):178 # a = LoginPage()179 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')180 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")181 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")182 # self.click_button(a.LOGIN_BUTTON)183 # self.click_button(can)184 # 删除r和药品185 self.click_button(can1)186 # 选择删除人187 self.click_button(can2)188 # 点击产删除189 self.click_button(can3)190 # 点击确定191 self.click_button(can4)192 self.refresh()193 def xiugai_interdace(self,can1,can2,can3,can4,can5,ida={},tele={}):194 # a = LoginPage()195 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')196 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")197 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")198 # self.click_button(a.LOGIN_BUTTON)199 # 信息修改200 self.click_button(can1)201 # 顾客修改202 self.click_button(can2)203 # 输入编号204 self.send_keys(locator=ida["locator"], value=ida["value"])205 # 点击查询206 self.click_button(can3)207 # 修改内容208 self.send_keys(locator=tele["locator"], value=tele["value"])209 # 点击修改210 self.click_button(can4)211 # 点击确定212 self.click_button(can5)213 self.refresh()214 def xiugai_pope_yaop(self,can1,cnn2,can3,can4,ida={},te={}):215 # 人修改216 self.click_button(can1)217 # 输入编号218 self.send_keys(locator=ida["locator"], value=ida["value"])219 # 点击查询220 self.click_button(can2)221 # 修改内容222 self.send_keys(locator=tele["locator"], value=tele["value"])223 # 点击修改224 self.click_button(can3)225 # 点击确定226 self.click_button(can4)227 self.refresh()228 def liulan_gk(self,can1,can2,can3,can4,can5):229 # a = LoginPage()230 # self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')231 # self.send_keys(locator=(a.USERNAME_INPUT), value="admir")232 # self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")233 # self.click_button(a.LOGIN_BUTTON)234 '''235 点击信息浏览236 点击浏览顾客237 选择顾客238 点击查看239 关闭窗口240 '''241 self.click_button(can1)242 self.click_button(can2)243 self.click_button(can3)244 self.click_button(can4)245 self.click_button(can5)246 self.refresh()247 def liulan_pope_yaop(self,can1):248 '''249 点击人和药品查看250 '''251 self.click_button(can1)252 def daying(self,can1,can2,can3,can4):253 '''254 点击数据报表255 点击顾客256 选择内容257 点击打印258 '''259 self.click_button(can1)260 self.click_button(can2)261 self.click_button(can3)262 self.click_button(can4)263 def dayin_pope_yaop(self,can1,can2,can3):264 '''265 点击顾客266 选择内容267 点击打印268 '''269 self.click_button(can1)270 self.click_button(can2)271 self.click_button(can3)272 def yonghu1_add(self,can1,can2,can3,user={},password={}):273 a = LoginPage()274 self.open_windows(url='http://47.111.8.42:8080/mms/mms/index.html')275 self.send_keys(locator=(a.USERNAME_INPUT), value="admir")276 self.send_keys(locator=(a.PASSWORD_INPUT), value="1234")277 self.click_button(a.LOGIN_BUTTON)278 '''279 用户管理280 用户管理281 添加282 输入用户283 输入密码284 点击save285 '''286 self.click_button(can1)287 self.click_button(can2)288 self.click_button(can3)289 self.send_keys(locator=user["locator"], value=user["value"])290 self.send_keys(locator=password["locator"], value=password["value"])291 self.click_button(can4)292 def yonghu_xiu(self,can1,can2,can3,can4,user={}):293 '''294 用户管理295 选择内容296 点击编辑297 修改用户298 点击save299 '''300 self.click_button(can1)301 self.click_button(can2)302 self.click_button(can3)303 self.send_keys(locator=user["locator"], value=user["value"])304 self.click_button(can4)305 def yoyhu_del(self,can1,can2,can3):306 '''307 选择内容308 点击删除309 点击确定310 '''311 self.click_button(can1)312 self.click_button(can2)...

Full Screen

Full Screen

Calculator Using Tkinter.py

Source:Calculator Using Tkinter.py Github

copy

Full Screen

...12def exit():13 e1.delete(0,"end")14 value = ""1516def click_button(number):17 global value18 value = value +str(number)19 entry_val.set(value)2021def equal_button():22 global value23 equal = eval(value)24 entry_val.set(equal)25 value = ""2627# Entry282930e1 = Entry(root , width = 40 ,textvariable = entry_val )31e1.place(x = 50 , y = 30)3233# Number Button Button3435b1 = Button(root,text = "1" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(1))36b1.place(x = 10,y = 100)3738b2 = Button(root,text = "2" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(2))39b2.place(x = 75,y = 100)4041b3 = Button(root,text = "3" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(3))42b3.place(x =140 ,y = 100)4344b4 = Button(root,text = "4" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(4))45b4.place(x = 10,y = 170)4647b5 = Button(root,text = "5" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(5))48b5.place(x = 75,y = 170)4950b6 = Button(root,text = "6" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(6))51b6.place(x =140 ,y = 170)5253b7 = Button(root,text = "7" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(7))54b7.place(x = 10,y = 240)5556b8 = Button(root,text = "8" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(8))57b8.place(x = 75,y = 240)5859b9 = Button(root,text = "9" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(9))60b9.place(x =140 ,y = 240)6162b0 = Button(root,text = "0" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button(0))63b0.place(x =10 ,y = 310)6465b_dot = Button(root,text = "." , padx =47 ,pady = 14 ,font=("arial 15"),command = lambda : click_button("."))66b_dot.place(x =75 ,y = 310)6768# calculation button697071add_b = Button(root,text = "+" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button("+"))72add_b.place(x =205 ,y = 100)7374sub_b = Button(root,text = "-" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button("-"))75sub_b.place(x =205 ,y = 170)7677mul_b = Button(root,text = "x" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button("*"))78mul_b.place(x =205 ,y = 240)7980div_b = Button(root,text = "/" , padx =14 ,pady = 14 ,font=("arial 15"),command = lambda : click_button("/"))81div_b.place(x =205 ,y = 310)8283# operational84#8586equal_b = Button(root,text = "=" , padx =14 ,pady = 48 ,font=("arial 15"),command = equal_button)87equal_b.place(x =270 ,y = 242)8889clear_b = Button(root,text = "C" , padx =14 ,pady = 48 ,font=("arial 15") , command = exit)90clear_b.place(x =270 ,y = 100)91929394root.mainloop()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run robotframework-appiumlibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful