How to use _get_remote_node_url method in toolium

Best Python code snippet using toolium_python

utilities.py

Source: utilities.py Github

copy

Full Screen

...281 self.logger.warning("Test video not found in node '%s'", remote_node)282 return283 self._download_video(video_url, video_name)284 @staticmethod285 def _get_remote_node_url(remote_node):286 logging.getLogger("requests").setLevel(logging.WARNING)287 grid_extras_port = 3000288 return 'http:/​/​{}:{}'.format(remote_node, grid_extras_port)289 def _get_remote_video_url(self, remote_node, session_id):290 url = '{}/​video'.format(self._get_remote_node_url(remote_node))291 timeout = time.time() + 5 # 5 seconds from now292 # Requests videos list until timeout or the video url is found293 video_url = None294 while time.time() < timeout:295 response = requests.get(url).json()296 try:297 video_url = response['available_videos'][session_id]['download_url']298 break299 except KeyError:300 time.sleep(1)301 return video_url302 def _download_video(self, video_url, video_name):303 from arc.core.driver.driver_manager import DriverManager304 filename = '{0:0=2d}_{1}'.format(DriverManager.videos_number, video_name)305 filename = '{}.mp4'.format(get_valid_filename(filename))306 filepath = os.path.join(DriverManager.videos_directory, filename)307 if not os.path.exists(DriverManager.videos_directory):308 os.makedirs(DriverManager.videos_directory)309 response = requests.get(video_url)310 open(filepath, 'wb').write(response.content)311 self.logger.info("Video saved in '%s'", filepath)312 DriverManager.videos_number += 1313 def is_remote_video_enabled(self, remote_node):314 enabled = False315 if remote_node:316 url = '{}/​config'.format(self._get_remote_node_url(remote_node))317 try:318 response = requests.get(url, timeout=5).json()319 record_videos = response['config_runtime']['theConfigMap']['video_recording_options'][320 'record_test_videos']321 except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout, KeyError):322 record_videos = 'false'323 if record_videos == 'true':324 # Wait to the video recorder start325 time.sleep(1)326 enabled = True327 return enabled328 def get_center(self, element):329 web_element = self.get_web_element(element)330 location = web_element.location...

Full Screen

Full Screen

driver_utils.py

Source: driver_utils.py Github

copy

Full Screen

...172 return173 self._download_video(video_url, video_name)174 elif server_type in ['ggr', 'selenoid']:175 Selenoid(self.driver_wrapper).download_session_video(video_name)176 def _get_remote_node_url(self, remote_node):177 """Get grid-extras url of a node178 :param remote_node: remote node name179 :returns: grid-extras url180 """181 logging.getLogger("requests").setLevel(logging.WARNING)182 gridextras_port = 3000183 return 'http:/​/​{}:{}'.format(remote_node, gridextras_port)184 def _get_remote_video_url(self, remote_node, session_id):185 """Get grid-extras url to download videos186 :param remote_node: remote node name187 :param session_id: test session id188 :returns: grid-extras url to download videos189 """190 url = '{}/​video'.format(self._get_remote_node_url(remote_node))191 timeout = time.time() + 5 # 5 seconds from now192 # Requests videos list until timeout or the video url is found193 video_url = None194 while time.time() < timeout:195 response = requests.get(url).json()196 try:197 video_url = response['available_videos'][session_id]['download_url']198 break199 except KeyError:200 time.sleep(1)201 return video_url202 def _download_video(self, video_url, video_name):203 """Download a video from the remote node204 :param video_url: video url205 :param video_name: video name206 """207 from toolium.driver_wrappers_pool import DriverWrappersPool208 filename = '{0:0=2d}_{1}'.format(DriverWrappersPool.videos_number, video_name)209 filename = '{}.mp4'.format(get_valid_filename(filename))210 filepath = os.path.join(DriverWrappersPool.videos_directory, filename)211 makedirs_safe(DriverWrappersPool.videos_directory)212 response = requests.get(video_url)213 open(filepath, 'wb').write(response.content)214 self.logger.info("Video saved in '%s'", filepath)215 DriverWrappersPool.videos_number += 1216 def is_remote_video_enabled(self, server_type, remote_node):217 """Check if the remote node has the video recorder enabled218 :param server_type: server type (grid, ggr, selenoid)219 :param remote_node: remote node name220 :returns: true if it has the video recorder enabled221 """222 enabled = False223 if server_type == 'grid' and remote_node:224 url = '{}/​config'.format(self._get_remote_node_url(remote_node))225 try:226 response = requests.get(url, timeout=5).json()227 record_videos = response['config_runtime']['theConfigMap']['video_recording_options'][228 'record_test_videos']229 except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout, KeyError):230 record_videos = 'false'231 if record_videos == 'true':232 # Wait to the video recorder start233 time.sleep(1)234 enabled = True235 elif server_type in ['ggr', 'selenoid']:236 enabled = True237 return enabled238 def get_center(self, element):...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Starting &#038; growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

Your Favorite Dev Browser Has Evolved! The All New LT Browser 2.0

We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.

Six Agile Team Behaviors to Consider

Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

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 toolium 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