-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
286 lines (212 loc) · 7.42 KB
/
Copy pathmain.py
File metadata and controls
286 lines (212 loc) · 7.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
"""Control Firefox through shortcuts"""
import pyautogui as auto
class Search:
"""Search commands for firefox"""
def __init__(self):
self.search_keyword = auto
def find(self):
"""find in the document"""
self.search_keyword.hotkey('Ctrl', 'F')
def find_again(self):
"""Find Again"""
self.search_keyword.hotkey('F3')
def find_previous(self):
"""Find Previous"""
self.search_keyword.hotkey('Shift', 'F3')
def quick_find_within_link_text(self):
"""Quick Find within link-text only"""
self.search_keyword.hotkey("'")
def quick_find(self):
"""Quick Find"""
self.search_keyword.hotkey('/')
def close_find(self):
"""Close the Find or Quick Find bar"""
self.search_keyword.hotkey('Esc')
def focus_search_bar(self):
"""Focus Search bar"""
self.search_keyword.hotkey('Ctrl', 'K')
def change_default_engine(self):
"""Change the Default Search Engine"""
self.search_keyword.hotkey('Ctrl', 'up')
def view_menu(self):
"""View menu to switch, add or manage search engines"""
self.search_keyword.hotkey('Alt', 'down')
class Navigation:
"""Firefox Browser navigation class"""
def __init__(self):
self.nav_browser = auto
def back(self):
"""Go back"""
self.nav_browser.hotkey('Alt', 'left')
def forward(self):
"""Go forward"""
self.nav_browser.hotkey('Alt', 'right')
def home(self):
"""go to the home web page"""
self.nav_browser.hotkey('Alt', 'Home')
def open_file(self):
"""Open folder"""
self.nav_browser.hotkey('Ctrl', 'o')
def reload(self):
"""Reload page """
self.nav_browser.hotkey('F5')
def reload_cache(self):
"""Reload page and cache"""
self.nav_browser.hotkey('Ctrl', 'F5')
def stop(self):
"""Stop the requests"""
self.nav_browser.hotkey('Esc')
class Edit:
"""Contains command to edit the text in web page"""
def __init__(self):
self.edit_keyboard = auto
def copy(self):
"""Copy the selected contend"""
self.edit_keyboard.hotkey('Ctrl', 'C')
def cut(self):
"""Cut the selected content"""
self.edit_keyboard.hotkey('Ctrl', 'X')
def delete(self):
"""Deletes when the contents is selected"""
self.edit_keyboard.hotkey('Del')
def delete_left_world(self):
"""Delete the world on the left"""
self.edit_keyboard.hotkey('Ctrl', 'Backspace')
def delete_right_world(self):
"""Delete the word on the right"""
self.edit_keyboard.hotkey('Ctrl', 'Del')
def go_one_world_left(self):
"""Move the cursor one word left"""
self.edit_keyboard.hotkey('Ctrl', '+', 'Left')
def go_one_world_right(self):
"""Move cursor one word right"""
self.edit_keyboard.hotkey('Ctrl', '+', 'Right')
def go_line_beginning(self):
"""Go to the beginning of the line"""
self.edit_keyboard.hotkey('Home')
def go_line_end(self):
"""Go to the end of the line"""
self.edit_keyboard.hotkey('End')
def go_text_beginning(self):
"""Go to the beginning of the text"""
self.edit_keyboard.hotkey('Ctrl', 'Home')
def go_end_text(self):
"""Go to the end of the text"""
self.edit_keyboard.hotkey('Ctrl', 'End')
def paste(self):
"""Past what ever is in clipboard"""
self.edit_keyboard.hotkey('Ctrl', 'V')
def paste_as_plain(self):
"""Paste as plain"""
self.edit_keyboard.hotkey('Ctrl', 'Shift', 'V')
def redo(self):
"""Redo action"""
self.edit_keyboard.hotkey('Ctrl', 'Shift', 'Z')
def select_all(self):
"""Select all content"""
self.edit_keyboard.hotkey('Ctrl', 'A')
def undo(self):
"""Undo action"""
self.edit_keyboard.hotkey('Ctrl', 'Z')
class Page:
"""working os the content of the page"""
def __init__(self):
"""Shortcuts working with a web page"""
self.page_control = auto
def focus_next(self):
"""Go to next focus"""
self.page_control.hotkey('Tab')
def previous_focus(self):
"""Go to previous focus"""
self.page_control.hotkey('Shift', 'Tab')
def go_down(self):
"""Go down the page"""
self.page_control.hotkey('Down')
def go_up(self):
"""Go up the page"""
self.page_control.hotkey('Up')
def go_bottom(self):
"""Go to the bottom of the page"""
self.page_control.hotkey('End')
def go_top(self):
"""Go to the top of page"""
self.page_control.hotkey('Home')
def next_frame(self):
"""Go to next frame"""
self.page_control.hotkey('F6')
def previous_frame(self):
"""Go to previous frame"""
self.page_control.hotkey('Shift', 'F6')
def print_page(self):
"""Print the page"""
self.page_control.hotkey('Ctrl', 'P')
def save_focused_link(self):
"""Save the focused link it works when browser.altClickSave is set to true"""
self.page_control.hotkey('Alt', 'Enter')
def save_page_as(self):
"""Save the page as, yuo chose the name and destination to save it"""
self.page_control.hotkey('Ctrl', 's')
def zoom_in(self):
"""Zoom in the page"""
self.page_control.hotkey('Ctrl', '+')
def zoom_out(self):
"""Zoom out the page"""
self.page_control.hotkey('Ctrl', '-')
def reset_zoom(self):
"""Reset the zoom to 0"""
self.page_control.hotkey('Ctrl', '0')
class Tools:
"""Working with the borwser's tool box"""
def __init__(self):
self.tool_box = auto
def downloads(self):
"""open downloads"""
self.tool_box.hotkey('Ctrl', 'Shift', 'Y')
def add_ons(self):
"""open add ons"""
self.tool_box.hotkey('Ctrl', 'Shift', 'A')
def developer_tools(self):
"""open tool box"""
self.tool_box.hotkey('F12')
def web_console(self):
"""open web console"""
self.tool_box.hotkey('Ctrl', 'Shift', 'K')
def inspector(self):
"""open inspector"""
self.tool_box.hotkey('Ctrl', 'Shift', 'C')
def debugger(self):
"""open debugger"""
self.tool_box.hotkey('Ctrl', 'Shift', 'S')
def style_editor(self):
"""open style editor tool box"""
self.tool_box.hotkey('Shift', 'F7')
def profiler(self):
"""open profiler tool box"""
self.tool_box.hotkey('Shift', 'F5')
def network(self):
"""open network tool box"""
self.tool_box.hotkey('Ctrl', 'Shift', 'E')
def developer(self):
"""open developer tool box"""
self.tool_box.hotkey('Shift', 'F2')
def design_view(self):
"""open design view"""
self.tool_box.hotkey('Ctrl', 'Shift', 'M')
def scratchpad(self):
"""open scratch pad"""
self.tool_box.hotkey('Shift', 'F4')
def page_source(self):
"""open the source code in new tab"""
self.tool_box.hotkey('Ctrl', 'u')
def console(self):
""""open browser console"""
self.tool_box.hotkey('Ctrl', 'Shift', 'j')
def page_info(self):
"""view page info"""
self.tool_box.hotkey('Ctrl', 'I')
# one test case
if __name__ == '__main__':
firefox = Tools()
import time
time.sleep(8)
firefox.console()