How to use go_to_url method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

prepare_final_data.py

Source:prepare_final_data.py Github

copy

Full Screen

1import pandas as pd2from utils.common.db_utils import read_all_results3from utils.common.nlp import tokenize_alphanum4from utils.common.datapipeline import DataPipeline5import re6_pattern = re.compile('[\W_]+')7def remove_dodgy_chars(text):8 return " ".join([_pattern.sub('', t)9 for t in text.split()])10def remove_acronyms(text, ignore=[]):11 _text = []12 just_skipped = False13 for word in text.split():14 if word.lower() in ignore:15 just_skipped = False16 _text.append(word)17 continue18 n_caps = sum(char.isupper() for char in word)19 if n_caps > 1 and len(word) < 6:20 just_skipped = True21 continue22 elif just_skipped and len(word) < 4 and n_caps > 0:23 just_skipped = True24 continue25 just_skipped = False26 if word.lower() == "degree":27 continue28 _text.append(word)29 if len(_text) < 3:30 return None31 return " ".join(_text)32def level_checker(query, levels=["bachelor", "master",33 "phd", "diploma", "doctor"]):34 # Check if the qualification type is in the query35 for lvl in levels:36 if lvl in query:37 return lvl38 return None39def get_qual_type(query, qual_map):40 _q = tokenize_alphanum(query)41 lvl = level_checker(_q)42 if lvl is not None:43 return lvl44 # Otherwise, search for the acronym45 for word in _q:46 for qual, acronyms in qual_map.items():47 if word in acronyms:48 return level_checker(qual)49 return None50def assign_category(x, kws):51 for label, kw in kws:52 if any(k in x.lower() for k in kw):53 return label54def assign_category_split(x, kws):55 for label, kw in kws:56 for k in kw:57 if k is None:58 continue59 if all(w in x.lower() for w in k.split()):60 return label61 return "Other"62def run(config):63 # Read qualifications64 qual_map = {}65 _results = read_all_results(config, "quals_db", "input_table_quals")66 for std, abbrv in _results:67 if abbrv not in qual_map:68 qual_map[abbrv] = set()69 qual_map[abbrv].add(std)70 _results = read_all_results(config, "input_db", "input_table")71 output = []72 for top_url, found_on_url, go_to_url, text in _results:73 # Reject courses which don't contain these basic words74 # (they should since they've been standardised)75 text = remove_dodgy_chars(text)76 if not any(r in text.split()77 for r in ["of", "in"]):78 continue79 if any(r in text.lower().split()80 for r in ["university", "college", "usa", "uk",81 "canada", "france", "spain"]):82 continue83 if "school of" in text.lower():84 continue85 text = remove_acronyms(text, ignore=["phd", "it"])86 if text is None:87 continue88 if len(text.split()) > 11:89 continue90 # Try to get the qualification from the text91 qual = get_qual_type(text,qual_map)92 # Otherwise, try to get the qualification from the URL93 if qual is None and go_to_url is not None:94 qual = get_qual_type(go_to_url,qual_map)95 # Finally, if a qualification has been found, require96 # require the text starts with the qualification97 if qual is not None:98 if not text.lower().startswith(qual):99 qual = None100 if qual is None:101 continue102 row = dict(top_url=top_url,103 found_on_url=found_on_url,104 go_to_url=go_to_url,105 course_name=text,106 qualification=qual)107 output.append(row)108 df = pd.DataFrame(output)109 df = df.drop_duplicates(["go_to_url", "course_name"])110 # Broad category-keyword matching111 kws = list((("Education", ('education', 'teaching',)),112 ("Science", ('bio',)),113 ("Comp/IT", ('comp', ' it ', 'info',114 'network', 'software', 'security')),115 ("Engineering", ('eng',)),116 ("Medical", ('health', 'medic', 'nursing', 'pharma',)),117 ("Business/Finance", ('business', 'manag', 'admin',118 'financ', 'commerce', 'account',)),119 ("Science", ('science',)),120 ("Other", ('',))))121 df["broad_category"] = df.course_name.apply(assign_category, kws=kws)122 kws = list((("Education", ('education', 'teaching',)),123 ("Water", ('water',)),124 ("Renewable and Clean Energy", ('energy', 'renewable',125 'climate', 'environ',)),126 ("Space", ('space', 'astro', 'aero',)),127 ("Technology", ('electric',)),128 ("Transportation", ('transport', 'mechanical',)),129 ("Technology", ('comp', ' it ', 'info', 'network',130 'software', 'eng', 'security',)),131 ("Health", ('health', 'medic', 'nursing', 'pharma',)),132 ("Technology", ('tech',)),133 ("Other", ('',))))134 df["priority_sector"] = df.course_name.apply(assign_category, kws=kws)135 kws = list((("Education Innovation and Technology",136 ("education policy", "education tech", "online education")),137 ("Aerospace Advanced Materials, Manufacturing, Maintenance and Testing",138 ("aerospace", )),139 ("Health Information Technology and Bioinformatics",140 ("medical", "health technology")),141 ("Public Health, Non-Communicable Diseases and Wellness",142 ("public health", "health admin", "health management")),143 ("Biotechnology and Genomics",144 ("biotech", "biology", "biochemistry")),145 ("Water Management and Economics",146 ("water", "agribusiness")),147 ("Solar and Alternative Energy Technology Systems",148 (None,)),149 ("Space Sciences",150 ("space",)),151 ("Cubesats and Nanosatellites",152 (None,)),153 ("Financial Services Technology",154 ("ebusiness",)),155 ("Cybersecurity",156 ("cyber", "information technology", "system security",157 "information security")),158 ("Internet of Things and Big Data",159 ("network",)),160 ("Semiconductor Process Development",161 ("elec engineering", "physics")),162 ("Robotics and Artificial Intelligence",163 (None,)),164 ("Smart City Applications and Solutions",165 ("health safety", "sustainable infrastructure")),166 ("Architecture and Urban Design",167 ("urban planning",168 "logical design", "building design", "architect")),169 ("Arabic Digital Technology",170 (None,)),171 ("Petroleum Geosciences",172 ("petrol",)),173 ("Additive Manufacturing (3D Printing)",174 ("material",)),175 ("Advanced Building and Construction Materials",176 ("civil engineering",)),177 ("Food Security",178 ("food science",)),179 ("Transportation Logistics, Analytics and Security",180 ("logistics",)),181 ("Commercial Unmanned Aerial Vehicles",182 ("aviation",)),183 ("Autonomous Vehicles",184 (None,))))185 df["focus_area"] = df.course_name.apply(assign_category_split, kws=kws)186 config["GoogleDrive"]["target-repo"] = "tier-2"187 with DataPipeline(config) as dp:188 for row in df.to_dict(orient="records"):...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1import sys23from PyQt5.QtCore import QUrl4from PyQt5.QtWebEngineWidgets import QWebEngineView5# Web Browser (HTML Frame)6from PyQt5.QtWidgets import *78class Window(QMainWindow):9 def __init__(self, *args, **kwargs):10 super(Window, self).__init__(*args, **kwargs)11 self.browser = QWebEngineView()12 self.browser.setUrl(QUrl('https://www.DuckDuckGo.com'))13 self.browser.urlChanged.connect(self.update_AddressBar)14 self.setCentralWidget(self.browser)15 self.status_bar = QStatusBar()16 self.setStatusBar(self.status_bar)1718 self.navigation_bar = QToolBar('Navigation Toolbar')19 self.addToolBar(self.navigation_bar)2021 back_button = QAction("Back", self)22 back_button.setStatusTip('Go to previous page you visited')23 back_button.triggered.connect(self.browser.back)24 self.navigation_bar.addAction(back_button)2526 refresh_button = QAction("Refresh", self)27 refresh_button.setStatusTip('Refresh this page')28 refresh_button.triggered.connect(self.browser.reload)29 self.navigation_bar.addAction(refresh_button)3031 next_button = QAction("Next", self)32 next_button.setStatusTip('Go to next page')33 next_button.triggered.connect(self.browser.forward)34 self.navigation_bar.addAction(next_button)3536 home_button = QAction("Home", self)37 home_button.setStatusTip('Go to home page')38 home_button.triggered.connect(self.go_to_home)39 self.navigation_bar.addAction(home_button)4041 self.navigation_bar.addSeparator()4243 self.URLBar = QLineEdit()44 self.URLBar.returnPressed.connect(lambda: self.go_to_URL(QUrl(self.URLBar.text()))) # This specifies what to do when enter is pressed in the Entry field45 self.navigation_bar.addWidget(self.URLBar)4647 self.addToolBarBreak()4849 # Adding another toolbar which contains the bookmarks50 bookmarks_toolbar = QToolBar('Bookmarks', self)51 self.addToolBar(bookmarks_toolbar)5253 Github = QAction("Github", self)54 Github.setStatusTip("Go to Github website")55 Github.triggered.connect(lambda: self.go_to_URL(QUrl("https://github.com/Game-Dev2233/My-Web-Browser/")))56 bookmarks_toolbar.addAction(Github)5758 Youtube = QAction("Youtube", self)59 Youtube.setStatusTip("Go to Youtube")60 Youtube.triggered.connect(lambda: self.go_to_URL(QUrl("https://www.Youtube.com")))61 bookmarks_toolbar.addAction(Youtube)6263 Netflix = QAction("Netflix", self)64 Netflix.setStatusTip("Go to Netflix")65 Netflix.triggered.connect(lambda: self.go_to_URL(QUrl("https://www.Netflix.com")))66 bookmarks_toolbar.addAction(Netflix)6768 YoutubeM = QAction("Youtube Music", self)69 YoutubeM.setStatusTip("Go to Youtube Music")70 YoutubeM.triggered.connect(lambda: self.go_to_URL(QUrl("https://music.youtube.com/")))71 bookmarks_toolbar.addAction(YoutubeM)7273 StackO = QAction("Stack Overflow", self)74 StackO.setStatusTip('Go to Stack Overflow')75 StackO.triggered.connect(lambda: self.go_to_URL(QUrl("https://stackoverflow.com/")))76 bookmarks_toolbar.addAction(StackO)7778 BakeBook = QAction("BakeBook", self)79 BakeBook.setStatusTip('BakeBook')80 BakeBook.triggered.connect(lambda: self.go_to_URL(QUrl("https://88oewp.wixsite.com/bakebook")))81 bookmarks_toolbar.addAction(BakeBook)8283 self.browser.maximumSize()84 self.show()8586 def go_to_home(self):87 self.browser.setUrl(QUrl('https://www.DuckDuckGo.com/'))8889 def go_to_URL(self, url: QUrl):90 if url.scheme() == '':91 url.setScheme('https://')92 self.browser.setUrl(url)93 self.update_AddressBar(url)9495 def update_AddressBar(self, url):96 self.URLBar.setText(url.toString())97 self.URLBar.setCursorPosition(0)9899100app = QApplication(sys.argv)101app.setApplicationName('Fast Python Browser')102103window = Window() ...

Full Screen

Full Screen

app.py

Source:app.py Github

copy

Full Screen

1from sys import argv as argv23from PyQt5.QtCore import QUrl4from PyQt5.QtCore import *5from PyQt5.QtGui import *6from PyQt5.QtWidgets import *7from PyQt5.QtWebEngineWidgets import QWebEngineView8 9from PyQt5.QtWidgets import *101112class Window(QMainWindow):13 def __init__(self, *args, **kwargs):14 super(Window, self).__init__(*args, **kwargs)15 16 self.browser = QWebEngineView()17 self.browser.setUrl(QUrl('https://www.google.com'))18 self.browser.urlChanged.connect(self.update_AddressBar)19 self.setCentralWidget(self.browser)2021 self.status_bar = QStatusBar()22 self.setStatusBar(self.status_bar)2324 self.navigation_bar = QToolBar('Navigation Toolbar')25 self.addToolBar(self.navigation_bar)2627 back_button = QAction("Back", self)28 back_button.setStatusTip('Go to previous page you visited')29 back_button.triggered.connect(self.browser.back)30 self.navigation_bar.addAction(back_button)3132 refresh_button = QAction("Refresh", self)33 refresh_button.setStatusTip('Refresh this page')34 refresh_button.triggered.connect(self.browser.reload)35 self.navigation_bar.addAction(refresh_button)363738 next_button = QAction("Next", self)39 next_button.setStatusTip('Go to next page')40 next_button.triggered.connect(self.browser.forward)41 self.navigation_bar.addAction(next_button)4243 home_button = QAction("Home", self)44 home_button.setStatusTip('Go to Google')45 home_button.triggered.connect(self.go_to_home)46 self.navigation_bar.addAction(home_button)4748 self.navigation_bar.addSeparator()4950 self.URLBar = QLineEdit()51 self.URLBar.returnPressed.connect(lambda: self.go_to_URL(QUrl(self.URLBar.text())))52 self.navigation_bar.addWidget(self.URLBar)5354 self.addToolBarBreak()5556 bookmarks_toolbar = QToolBar('Bookmarks', self)57 self.addToolBar(bookmarks_toolbar)5859 nerpPortal = QAction("N-ERP", self)60 nerpPortal.setStatusTip("Go To N-ERP Portal")61 nerpPortal.triggered.connect(lambda: self.go_to_URL(QUrl("https://nerps.sec.samsung.net/sap/bc/ui2/flp#Utility-home")))62 bookmarks_toolbar.addAction(nerpPortal)6364 samsungPortal = QAction("Samsung Portal", self)65 samsungPortal.setStatusTip("Go to Samsung Sales Portal")66 samsungPortal.triggered.connect(lambda: self.go_to_URL(QUrl("https://spwa.sec.samsung.com/login.do")))67 bookmarks_toolbar.addAction(samsungPortal)68 69 google = QAction("Samsung Portal", self)70 google.setStatusTip("Go to Facebook")71 google.triggered.connect(lambda: self.go_to_URL(QUrl("https://www.google.com")))72 bookmarks_toolbar.addAction(google)7374 self.show()7576 def go_to_home(self):77 self.browser.setUrl(QUrl('https://www.google.com'))7879 def go_to_URL(self, url: QUrl):80 if url.scheme() == '':81 url.setScheme('https://')82 self.browser.setUrl(url)83 self.update_AddressBar(url)8485 def update_AddressBar(self, url):86 self.URLBar.setText(url.toString())87 self.URLBar.setCursorPosition(0)888990app = QApplication(argv)91app.setApplicationName("Hemanth's Development WebBrowser")9293window = Window() ...

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