Libraries & Frameworks

I’m currently building a testing framework for functional tests. I can run them in parallel using Cucumber but I have run into a problem in creating users for each thread (each test requires a brand new user).

I have a user.properties file with details for each new user created. Duplication doesn’t matter for most fields and my emails are different each time because I use something like this “useremail” + System.currentTimeMillis + “@example.com”.

My problem arises when reusing phone numbers. It needs to be a valid phone number and cannot be duplicated across accounts. I tear down users with the phone number at the beginning of each test. But running over multiple threads causes clashes of numbers.

I have 2 stored numbers in my user.properties which I hope to cycle through using a synchronized method for each thread and lock that number to that thread. But I aim to have more than 2 threads (as many phones that I can attach to be honest).

Every solution I come up with feels hacky and I’m quite new to this. Does anyone know of a good solution to distribute a finite number of user properties across multiple threads so they don’t clash?

Thought of using the actual device or emulator’s number (not sure if appium can extract that), but even if I could, my numbers need to be UK numbers

Thanks for your help.

I am developing a Selenium Test Automation Framework for the purpose of testing multiple websites.

I have currently set up the Framework in Visual Studio using C# and implementing the Page Object Model.

The Framework itself is a C# project and the Test project is separate but references the Framework.

I am happy with the fundamentals of the Framework but I want to implement some Data Driven aspects in order to increase the durability of the tests. I currently have NUnit running paramaterised test using [TestCase] but the data is hardcoded by me.

The ideal scenario would be to add a DatabaseHelper class to the Framework which would allow me to define queries on the database under test to return values and Nunit would repeat the same test for each row of the SQL query.

Has anyone here implemented a similar method and how would you go about creating it?

I have a result file of Concurrency Thread Group test of 500 users.
The file has aproximetly 58K rows and 16Mb

1) I tried generating a report through “Tool > Generate html report” but get time-out exception, I have increased the timer to 480000 but the result was the same.

2) I tried generate report through cmd -> it was running for a few hours and again no result, no report, all logs files have no exceptions.

Is there limitation of a report’s rows?
please help!

So I am trying to write a test in which the first step is logging in, but it is denying me access as it detected automation tools because the javascript has not been enabled and there is no profile. So I am trying to load my default profile. The problem I’m getting is that the browser does open, but it quickly fails as I get a SessionNotCreatedException. The failure occurs in the service hooks:
@Before(“@FrontendTest”)
public void setup() {

System.setProperty(“webdriver.chrome.driver”,
“E:\interview_notcodegod\src\drivers\chromedriver.exe” );

ChromeOptions options = new ChromeOptions();

options.addArguments(“–enable-javascript”);

options.addArguments(“–user-data-dir=C:/Users/[username]/AppData/Local/Google/Chrome/User Data”);

WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(options); // intellij points here (nullpointerexception)
driver.manage().window().maximize();
}

Is there a line of code that i’m missing? I’ve updated my chromedriver already because I thought that was the issue (chrome Version 99.0.4844.74 (Official Build) (64-bit), chromedriver:99.0.4844.51)

I’m trying to code using UFT to handle privacy error pages. When i tried to scan this page using UFT, unable to recognise inner links and button. Its showing chrome legacy window.
So i thought of going with vb code. Can anyone help me in coding here which works in uft?

Is there is an open source to check the mobile application in the Safari browser?

Right now am using Responsive Web Design tester Add on chrome but in the add on we have some devices like iPhone and Ipad but it is running under the chrome browser.

During testing the same application in the Responsive Web Design tester is working as we expected but whenever testing in Ipad my test is failed and application is behaving wrongly while displaying the dashboard data

Can anyone please suggest me to any open source tool to check in Safari browser.

This is my code,
”’
import time

from selenium.webdriver.common.by import By

from selenium.webdriver import ActionChains

from selenium.webdriver.support import expected_conditions as EC

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
num = str(datetime.datetime.now())
driver = webdriver.Firefox(executable_path=”C:\geckodriver.exe”)
driver.get(“https://my.eventbuizz.com/_super/analytics_requests”)
driver.maximize_window()
time.sleep(4)
driver.find_element_by_name(“email”).send_keys(“text”)
driver.find_element_by_name(“password”).send_keys(“text”)
driver.find_element_by_xpath(“//input[@value=’login’]”).click()
time.sleep(5)
driver.find_element_by_xpath(“//span[contains(text(),’Google Analytics’)]”).click()
time.sleep(2)
driver.find_element_by_xpath(“//span[contains(text(),’Analytics Requests’)]”).click()
ActionChains = ActionChains(driver)
time.sleep(2)

lists = driver.find_elements_by_xpath(“//*[@class= ‘gradeA’]/td[1]”)
for list_item in lists:
print(len(lists))
print(type(lists))
print(list_item.text)
output = list_item.text

driver.execute_script(“window.open(”);”)
driver.switch_to.window(driver.window_handles[1])
time.sleep(2)
driver.get(“https://my.eventbuizz.com/_super/organizerEvent/organizerEventList”)
time.sleep(2)
driver.find_element_by_xpath(“//input[@id=’event_name’]”).send_keys(output)
time.sleep(2)
driver.find_element_by_xpath(“//input[@value=’Search’]”).click()
time.sleep(2)
time.sleep(3)
driver.find_element_by_xpath(“//a[normalize-space()=’Auto Login’]”).click()
time.sleep(5)

driver.switch_to.window(driver.window_handles[2])
time.sleep(4)
driver.find_element_by_xpath(“//input[@name=’searchText’]”).send_keys(output)
driver.find_element_by_xpath(“//input[@id=’btn_sbt’]”).click()
time.sleep(2)
driver.find_element_by_xpath(“//div[@class=’img-center’]//a”).click()
time.sleep(3)
event_name = driver.find_element_by_xpath(“//input[@id=’event_name’]”).get_attribute(‘value’)
print(“Event Name = ” + event_name)
time.sleep(5)
a = driver.find_element_by_xpath(“//body[1]/section[1]/section[1]/form[1]/div[1]/div[3]/div[3]/div[2]/em[1]”).text
ab = a[8:]
print(“Event URl = ” + ab)

driver.execute_script(“window.open(”);”)
driver.switch_to.window(driver.window_handles[3])
time.sleep(2)
driver.get(“https://analytics.google.com/analytics/web/#/a213435779w295029133p256179771/admin”)
time.sleep(4)
email_phone = driver.find_element_by_xpath(“//input[@id=’identifierId’]”)
time.sleep(2)
email_phone.send_keys(“eb.march.eventbuizz2021@gmail.com”)
driver.find_element_by_id(“identifierNext”).click()
password = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.XPATH, “//input[@name=’password’]”)))
password.send_keys(“text”)
driver.find_element_by_id(“passwordNext”).click()
time.sleep(20)
# driver.find_element_by_xpath(“//span[@class=’ga-dialog-title-close’]”).click()
# time.sleep(6)
driver.find_element_by_xpath(“//span[contains(text(),’Create Property’)]”).click()
time.sleep(4)
driver.find_element_by_xpath(“//input[@id=’name’]”).click()
time.sleep(4)
driver.find_element_by_xpath(“//input[@id=’name’]”).send_keys(event_name)
time.sleep(4)

countries = driver.find_elements_by_css_selector(“[class=’menu-open-button-label-text’]”)
for country in countries:
if country.text == “United Kingdom”:
country.click()
break
time.sleep(2)
country_name = driver.find_elements_by_css_selector(“[class=’option-container ng-star-inserted’]”)
for count in country_name:
if count.text == “Denmark”:
count.click()
break

time.sleep(2)
amount_code = driver.find_elements_by_xpath(“//div[@class=’option-item-wrapper ng-star-inserted’]”)
for code in amount_code:
if code.text == “Danish Krone (DKK DKK)”:
code.click()
break

time.sleep(2)
driver.find_element_by_xpath(“//span[contains(text(),’Show advanced options’)]”).click()
time.sleep(2)
driver.find_element_by_css_selector(“[class=’mat-slide-toggle-thumb’]”).click()
time.sleep(2)
end = driver.find_element_by_xpath(“//label[contains(text(),’Website URL’)]”)
driver.execute_script(“document.body.scrollIntoView();”, end)
time.sleep(2)
driver.find_element_by_xpath(“//input[@type=’url’]”).send_keys(ab)

driver.find_element_by_xpath(“//label[@for=’mat-radio-8-input’]//span[@class=’mat-radio-label-content’]”).click()
time.sleep(2)
driver.find_element_by_xpath(“//span[contains(text(),’Next’)]”).click()
time.sleep(2)

driver.find_element_by_xpath(“//label[@for=’mat-radio-2-input’]//span[@class=’mat-radio-label-content’]”).click()

time.sleep(3)
driver.find_element_by_xpath(“//label[@for=’mat-checkbox-2-input’]//span[@class=’mat-checkbox-inner-container’]”).click()
time.sleep(2)
driver.find_element_by_xpath(“//span[normalize-space()=’Create’]”).click()
time.sleep(20)
driver.switch_to.frame(“galaxyIframe”)
time.sleep(5)
track = driver.find_element_by_xpath(“//div[@class=’_GACjb’]”).text
print(print(“Tracking ID = ” + track))

driver.switch_to.default_content()
time.sleep(2)
driver.find_element_by_xpath(“//mat-icon[contains(text(),’arrow_back’)]”).click()
time.sleep(2)
driver.find_element_by_xpath(“//span[contains(text(),’View Access Management’)]”).click()
time.sleep(8)
driver.find_element_by_xpath(“//button[@aria-label=’Add access to new users’]//span[@class=’mat-button-wrapper’]”).click()
time.sleep(3)
driver.find_element_by_xpath(“//button[normalize-space()=’Add users’]”).click()
time.sleep(3)
driver.find_element_by_id(“mat-chip-list-input-0”).send_keys(
“analytics47@api-project-770804776074.iam.gserviceaccount.com”)
time.sleep(3)
driver.find_element_by_xpath(“//span[normalize-space()=’Add’]”).click()
time.sleep(5)
driver.find_element_by_xpath(“//mat-icon[normalize-space()=’close’]”).click()
time.sleep(3)
driver.find_element_by_xpath(“//span[contains(text(),’View Settings’)]”).click()
time.sleep(3)
view_id = driver.find_element_by_css_selector(“[class=’content view-id’]”).text
print(“View ID =” + view_id)
time.sleep(3)
driver.execute_script(“window.open(”);”)
driver.switch_to.window(driver.window_handles[4])
time.sleep(2)
driver.get(“https://my.eventbuizz.com/_admin/add_google_analytics”)
time.sleep(4)
driver.find_element_by_xpath(“//input[@placeholder=’Google analytics email’]”).clear()
time.sleep(2)
driver.find_element_by_xpath(“//input[@placeholder=’Google analytics email’]”).send_keys(
” analytics47@api-project-770804776074.iam.gserviceaccount.com”)
time.sleep(1)
driver.find_element_by_xpath(“//input[@placeholder=’Google Analytics Code’]”).clear()
time.sleep(2)
driver.find_element_by_xpath(“//input[@placeholder=’Google Analytics Code’]”).send_keys(track)
time.sleep(1)
driver.find_element_by_xpath(“//input[@placeholder=’Google profile ID’]”).clear()
time.sleep(2)
driver.find_element_by_xpath(“//input[@placeholder=’Google profile ID’]”).send_keys(view_id)
time.sleep(2)
driver.find_element_by_xpath(“//input[@class=’save-event’]”).click()
time.sleep(4)
driver.find_element_by_xpath(“//a[@class=’btn btn-sm log-out text-right’]”).click()
time.sleep(3)
driver.switch_to.window(driver.window_handles[5])
time.sleep(4)
driver.find_element_by_xpath(“//label[normalize-space()=’Statistics’]”).click()
time.sleep(2)
driver.find_element_by_xpath(“//a[normalize-space()=’Accept all cookies’]”).click()

time.sleep(5)
driver.switch_to.window(driver.window_handles[3])
driver.find_element_by_xpath(“//md-icon[@md-font-icon=’realtime-icon’]”).click()
time.sleep(3)
driver.find_element_by_xpath(“//span[@class=’ga-nav-link-label ga-nav-link-no-icon’]”).click()
time.sleep(3)
print(“************************ Google analytics added successfully **************************** “)

with open(‘Text.txt’, mode=’w’) as f:
f.write(“Event_name” + ” ” + “Event_Tracking_ID” + “n”)
for post in event_name:
f.write(post)
f.write(” “)
for post1 in track:
f.write(post1)
f.write(“n”)
driver.switch_to.window(driver.window_handles[0])
”’

I have a multi module application “Project A”. This application is hosted in clustered app nodes using tomcat as web server. We are using Spring, Web Services as primary among many other technologies to build this.

For doing the API Automation i have another project “Project B” which test all the public API of “Project A” using rest-assured.

Both the “Project A” and “Project B” are distinctly different and hosted in different GIT location. We do the build and test using Jenkins.

Now my requirement is to get code coverage of “Project A” using “Project B”.

What I have Done till now:

A. I have installed jacoco-agent.jar in each of my app node and put the “JACOCO-ARGS” in the web server start up script.

JACOCO_OPTS=”-javaagent:/opt/itop/jacoco-agent.jar=destfile=/opt/itop/jacoco-
it.exec,output=file,append=true,jmx=true”

JAVA_OPTS=”${JAVA_OPTS} ${JACOCO_OPTS}”

B. We usually keep one node on only while looking for code coverage.

What I am getting now:

I am getting the jacoco-it.exec file generated but with very less coverage. With all the API passing i am getting only 3% coverage at max. Where as by doing manual testing we are getting more than 50%.

What I am looking for:

Is there any other step which I am missing here?
How to get max code coverage for this set up?
What is the standard I need to follow while looking for code coverage?

White box testing is essential in software engineering, offering an in-depth view of internal code operations to enhance software quality and stability. This blog outlines the various types of white box testing, their importance in identifying and fixing code errors early in the development process, and the latest tools for 2024, such as JUnit and Selenium. White box testing ensures comprehensive code coverage and supports the development of robust, efficient applications by allowing detailed inspection and modification of the code.
The post Why is White Box Testing Essential in Software Engineering? first appeared on TestingXperts.

I am currently working on updating regression test suite. I would like to add some simple test at the beginning of the regression suite to make sure it is still behaving correctly and all the basic functionality still works (can perform basic operations and also it is able to connect to the database or other services) before proceed with full regression test suite. These test would not be specialized based on type of changes which were made to the software, but would only cover specific subset of regression tests, which would be the same for every new build. They would cover broad range of functionality. Would these test be considered more as sanity tests or smoke tests? Thank you.

This might be a trivial question/answer, however I would like to know if there is a way that I could store an element locator in a variable and then reuse it same as it while working with Selenium and Page Object Pattern.
In my previous work I used to write automation test in Visual Studio and I used Selenium Web-driver along with Page Object Pattern approach. During my work on the Page Objects and later component, I could declare all selectors by FindBy annotation and then reuse it for the purpose of future tests. I have just started my adventure with Playwright and I was wondering if I could achieve same approach. So far all examples in web showed that each time when you have an element selector you perform already an action on it.
Lets say that I have a Page Object Class called “Home Page”. On this page there is a “Submit” button. I would like to get location of this button and store in a variable so I can reuse it in the future. How can I achieve similar out which I used with FindBy annotation?
So instead of having common approach such as -> await page.click(‘button’);
I would like to have something which will look like this -> const submitButton= [location of button tag];
Thanks in advance for any guidance.

When I try to take a screenshot, I added a scroll so that it can take a significant screenshot and not only the header. Right now, the picture is still taken from the header/top of the page.
Am I doing something wrong?
Screenshot method :
public void ScreenShot() {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(“scroll(0,450);”);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(“yyyy-MM-dd HH_mm_ss”);
LocalDateTime now = LocalDateTime.now();
String destDir = System.getProperty(“user.dir”) + “/” + “test-output/ScreenShots”;
String FileName = “SoftAssertScreenshot_” + dtf.format(now) + “.png”;
String DestFile = destDir + “/” + FileName;
File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
File ScreenshotName = new File(DestFile);
try {
FileUtils.copyFile(file, ScreenshotName);
} catch (IOException e) {
e.printStackTrace();
}
Reporter.log(“</br><font color=’#73a9d0′>***************Screen Of the error****************</font>”);
Reporter.log(“</br><img id=’ErrorResult’ src='” + DestFile + “‘ style=’width:600px’/>”);
}

The chrome browser version is Version 115.0.5790.171 and downloaded chrome driver version is 114
[![enter image description here][1]][1]
as driver version 115 is not available.
I’m using the x-path and checked the x-path is correct or not in developer tool under console section it is correct. Even tried absolute path given by Automation Tester but still getting as No such element is found
[![enter image description here][2]][2]
[![enter image description here][3]][3]
This x-path is getting due to chrome browser version is 115 and chrome driver version is 114 using due to unavailable.
Could someone please help me
[1]: https://i.stack.imgur.com/RnSVN.png
[2]: https://i.stack.imgur.com/ydrhs.png
[3]: https://i.stack.imgur.com/hXedl.png

Assumptions, imagine we are selling a software API:

a “system test” verifies that a system works by calling it’s public interface e.g. assert(init()==true) or assert(MY_PI > 2 && MY_PI <= 10)
a set of “unit tests” verifies the public interface of implementation details (assuming OOP: all public methods and fields) does what is expected
an “integration test” is something in between and is not really important for the question.

What I wonder is what is the term/s for more localized whitebox tests :

private methods(and if You cluster that with “unit”, what about lambdas?)
assert()*s peppered inside methods/functions.

* – referring to C++ asserts which compile to no operation in release code; not python asserts which are beautiful ifs