Retrieve all DOM elements in WebUI in Katalon Studio - katalon-studio

Is there a way to retrieve all DOM elements in Katalon Studio so that I can execute actions with them randomly?

import org.openqa.selenium.WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.By
WebUI.openBrowser('forum.katalon.com')
WebDriver driver = DriverFactory.getWebDriver()
elements = driver.findElements(By.xpath("//*"))
Try this and see if it helps.

Related

AttributeError for selfloop_edges()

When executing the following:
import networkx as nx
import matplotlib.pyplot as plt
import csv
with open("nutrients.csv") as file:
reader = csv.reader(file)
G = nx.Graph(reader) #initialize Graph
print(G.nodes()) #this part works fine
print(repr(G.edges))
G.selfloop_edges()#attribute of question
It's coming back with
AttributeError:"Graph" object has no attribute 'selfloop_edge'
Does anyone know what could be the issue?
You getting an error because this method has been moved from the base graph class into the main namespace, see Migration guide from 1.X to 2.0. So either you're looking at the docs of 1.X or using code from previous releases.
You need to call this method as:
nx.selfloop_edges(G, data=True)

Add import within a snippet - VS Code

I am writing a code snippet in Visual Studio Code, and I need that the snippet will import libraries if they are not already imported.
A simple example: I want to create a snippet in Java that will create a new Scanner and close it:
"Scanner": {
"prefix": "scanner",
"body": [
"Scanner scanner = new Scanner(System.in);",
"scanner.close();"]
}
I need that if the code doesn't contain an import for java.util.Scanner it will be imported (as part of the snippet).
How can I do it?

Export page text from Katalon Recorder

Just getting started with Katalon Recorder. After navigating and loading a page, is there a way to store the entire page text? I am trying to automate a function where I have to click into a list item, select all, copy and paste into excel.
The comment from Mate Mrše is off to a good start. Here's some example code that fleshes out the details. The following code saves the page to an html file. From there you'll need additional processing to put it into another document format, such as Excel.
// add the following two imports for the webdriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.WebDriver as WebDriver
// open browser/navigate, etc
// WebUI.openBrowser('https://google.com')
WebUI.delay(5)
WebDriver driver = DriverFactory.getWebDriver()
def src = driver.getPageSource()
def file1 = new File('c:/1/the_saved_web_page.htm')
file1.write(src)

How to attach screenshots to the allure-behave html report? For pytest it runs fine but 'behave' , no attachment gets added

I am using allure framework to generate reports for my pytest tests and behave (BDD) tests. In pytest the code is:
import allure
from allure.constants import AttachmentType
#use the below statement to attach the screenshot
allure.attach('screenshot', self.driver.get_screenshot_as_png(), type=AttachmentType.PNG)
However, I am unable to find a similar way in behave to attach the screenshots to my html report
You need install allure-pytest and then:
from allure_commons._allure import attach
from allure_commons.types import AttachmentType
attach(
self.driver.get_screenshot_as_png(),
name="Screenshot",
attachment_type=AttachmentType.PNG
)
You can attach something to step with code like this:
import allure
from behave import given
#given(u'passed step')
def step_impl(*args, **kwargs):
allure.attach(driver.get_screenshot_as_png(), name='screenshot', attachment_type=allure.attachment_type.PNG)
from behave import *
from allure_commons._allure import attach
from allure_commons.types import AttachmentType
#Then(u'passed step')
def step_impl(*args, **kwargs):
driver.save_screenshot('screenshot.png')
try:
allure.attach('screenshot.png', name='screenshot', attachment_type=allure.attachment_type.PNG)
except Exception as e:
print(e)
Probably you dont have to use 'try', check the status here:
https://github.com/allure-framework/allure-python/issues/431

Import {} from location is not found in VS Code using TypeScript and Angular 2

I am trying out the new Angular 2 Forms. My import statements are as follows:
import {bootstrap, onChange, NgIf, Component, Directive, View, Ancestor} from 'angular2/angular2';
import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms';
import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';
import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
The 'angular2/angular2' resolves fine, but none of the other "from" locations resolve. The error is:
Cannot find module 'angular2/forms'.
All of these components are currently in my node_modules directory. If I put in the full path:
import {formDirectives, ControlDirective, Validators, TemplateDrivenFormDirective} from 'C:/Users/Deb/node_modules/angular2/forms';
then it works. However, I should not need to use the full path. Am I missing something when I set up the tsconfig or is there something else wrong?
Problem was that the example application did not match with the version of Angular 2 currently available for download.
If anyone is interested, I now have a working example of Angular2 forms with TypeScript and Visual Studio Code here:
https://github.com/DeborahK/AngularU2015-Angular2Forms
Hope this helps anyone else standing on the "bleeding edge".