Libraries & Frameworks

API testing is a critical aspect of software testing as APIs serve as the communication channels between different software components, allowing them to interact and exchange data. API testing not only involves validating the functionality, but also the performance, security, and reliability of APIs to ensure they meet the intended requirements and perform as expected.
The post The Only API Testing Checklist You Need in 2024 appeared first on Codoid.

We are currently testing out DevOps but one thing that I can’t do is have MSTest hit our internal server (which is housed in Azure) that contains selenium and such.
DevOps of course is external.
I am no networking guru, but is there a way to build a connection between the two?
Or do we have to make our selenium server outward facing?

I have the following code

driver.find_element_by_id(“Element_ID”).send_keys(str(sheet.cell(row=r, column=2).value))

Values is taken from excel, but instead send_keys, I want to use document.getElementsByName script.

How can I adapt the getElementsByName script for my situation?

I’m wondering what some other options are for accessing the test automation framework dependencies from my test classes.
Right now I have a layered architecture:

Framework layer (contains all shared code for accessing deployed services)
Harness layer (builds the classes and dependencies within the framework. Ie handles DI)
Test layer (controls the flow of the tests via the objects created in the harness)

I’ve got a test base class in the harness layer that has access to the various API, database, and UI classes needed to run our tests. So using inheritance to provide access to these dependencies.
A sample test class would look like:
public class MyTestClass : TestBase
{
[Test]
public void sample_test()
{
APIs.MyAPI.GetSampleEndpoint(); // APIs is an inherited field in test base
}
}

I feel inheritance is the best way to go about the issue of dependencies within a test class. The downside is managing the wrapping class that the “APIs” field is attached to.
Are there better options to go about managing a large list of dependencies in a clean way?

Selenium webdriver is not able to pull up the chrome dev tools. From what it looks like puppeteer could do this, but will it give me a way to save the interactive timeline report? Can puppeteer be run in a headfull mode? in an incognito tab? I saw the developers page but no specific examples

I have a test scenario where the web application checks for the user’s leave intent i.e., mouse hovering from the page to the browser close and then a frame gets triggered. Is there any way to do it?

Edit: So the dev implementation is that when the user is moving to the top of the document frame gets triggered and it is not browser close but moving to corner of the document.

I am using Selenium 4 in java to control Chrome and Edge and other browsers in order to test a video call app. I have a test where I’m starting up 2 different browsers at once in order to get them to communicate with each-other. I am using OBS to provide virtual webcams with customizable feeds so that I can switch input for either browser.
When I start up 2 Chromium-family browsers I get an issue that only the first one I launch (at a time) can get and show the full list of cameras while the other one shows nothing – even after waiting 15+ minutes. If I launch Firefox and Chrome as my browsers then they both can access the webcam list.
Since Firefox is not planned to be supported for the first version of the webapp, that leaves mostly chromium family browsers for me to test with (I’m on windows so I can’t test safari at this point). Does anyone know why this is happening and how I could fix it?
How I start Chrome:
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.addArguments(“use-fake-ui-for-media-stream”);
chromeDriver = new ChromeDriver(chromeOptions);

How I start Edge:
EdgeOptions edgeOptions= new EdgeOptions();
edgeOptions.addArguments(“use-fake-ui-for-media-stream”);
edgeDriver = new EdgeDriver(edgeOptions);

How I start Firefox:
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.addPreference(“browser.cache.disk.enable”, false);
firefoxOptions.addPreference(“browser.cache.disk.capacity”, 0);
firefoxOptions.addPreference(“browser.cache.disk.smart_size.enabled”, false);
firefoxOptions.addPreference(“browser.cache.disk.smart_size.first_run”, false);
firefoxOptions.addPreference(“browser.sessionstore.resume_from_crash”, false);
firefoxOptions.addPreference(“browser.startup.page”, 0);
firefoxOptions.addPreference(“media.navigator.permission.disabled”, true);
firefoxOptions.addPreference(“device.storage.enabled”, false);
firefoxOptions.addPreference(“media.gstreamer.enabled”, false);
firefoxOptions.addPreference(“browser.startup.homepage”, “about,blank”);
firefoxOptions.addPreference(“browser.startup.firstrunSkipsHomepage”, false);
firefoxOptions.addPreference(“extensions.update.enabled”, false);
firefoxOptions.addPreference(“app.update.enabled”, false);
firefoxOptions.addPreference(“network.http.use-cache”, false);
firefoxOptions.addPreference(“browser.shell.checkDefaultBrowser”, false);
firefoxDriver = new FirefoxDriver(firefoxOptions);

In this code i want to navigate to the year 2022 and select July and print that result in the console but the issue is that in the else if condition when checking when this particular condition is encounted where the year is 2022 and the month is december it is passing and it is navigating to next Button which is January 2023 so the loop keeps on running and i cannot get my desired result
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

public class DatePicker {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5000));

driver.get(“https://seleniumpractise.blogspot.com/2016/08/how-to-handle-calendar-in-selenium.html”);

driver.findElement(By.id(“datepicker”)).click();

String desiredMonth = “July”;
String desiredYear = “2022”;

while (true) {
String year1 = driver.findElement(By.className(“ui-datepicker-year”)).getText();
String month1 = driver.findElement(By.className(“ui-datepicker-month”)).getText();

if (year1.equals(desiredYear) && month1.equalsIgnoreCase(desiredMonth)) {
System.out.println(“Desired date reached: the year is ” + year1 + ” and the month is ” + month1);
break;
} else if (year1.equals(desiredYear) && month1.compareTo(desiredMonth) < 0) {
driver.findElement(By.className(“ui-icon-circle-triangle-e”)).click();
} else {
driver.findElement(By.className(“ui-icon-circle-triangle-w”)).click();
}

// Wait for the changes to take effect
wait.until(ExpectedConditions.presenceOfElementLocated(By.className(“ui-datepicker-year”)));
}

driver.quit();
}
}

I am trying to use this xpath to find the number of elements that have a value between X and Y. The problem I am facing is since there is &nbsp in the HTML, and the code doesn’t detect the text value.
Xpath:
//div[@class=”prix”]/div[2]/div[2]/span[1][number(translate(text(), “,”, “.”)) > 4 and number(translate(text(), “,”, “.”)) < 43]

HTML :
<div class=”d-flex-inline productPrice”>
<span>4,42&nbsp;</span>
<span>€/HT</span>
</div>

I tried with replace(text(),” “,””) and replace(text(),”&nbsp;”,””) and other combinations but nothing worked.

I am confused to see what Appium version is installed on my machine. If I look into Appium UI it shows Appium v1.22.3 but When I check from cmd it shows 2.0.0-beta.71. how do I know which one is correct?

I am writing up a white paper to introduce Agile. As my role is a QA engineer working for a consultancy company.

We want customers to hire us to train them in implementing Agile and we DO want our customers to be aware of various traps when implementing Agile as well as false expectations.

I am thinking of adding some scenarios that show if Agile is not properly implemented, it may backfire on you.

Have you experienced any scenarios where Agile does not improve efficiency or even hurdle coding?

Background

We are currently moving API testing from the Technical testing team to the development team. The technical testing team has a formal process where they write the test objectives and test cases prior to developing the script in SOAPUI. Therefore, analyzing the specification and supporting requirements document are important for deriving the tests.

In the new world the developers will code/point and click their unit tests and there will be no other QA other than the UAT of the consumption of API, which can happen between a month to three months after the API has been created. The API is not an open API, only for third party suppliers and internal web and app resources.

There is an argument that additional QA work is not needed if the developers are writing the unit tests, so developers do not need to have an analysis phase or write test cases prior to setting them up in SOAPUI or coding the test.

We create enterprise level financial websites and applications. The teams is 30+ strong.

Question

Should developers still perform such analysis and write test cases?

Example test case: Check mobile bill payment after due date.

For the above test case, different telecom operators have different sets of rules. For example, some allow payment after due date, and some don’t.

I am confused on how to write a test case for this situation; the same test case may PASS or FAIL based on the test data.

Do I need to repeat the same test case for different sets of data based on rules?

I have found this on one site “Data-driven testing is taking a test, parameterizing it, and then running that test with varying data”. How I can add parameters and results in to an Excel document in which I’ll write test cases?

Please suggest a way to prepare test cases for scenarios like this.

I am asking in case I run into this scenario in the future.

Someone in my company wrote multiple methods with 25 parameters. I don’t know how/why it got thru code review. I’m just wondering how someone would write unit test cases in junit for this? The number of combinations/permutations would be crazy.

I know the real solution is to rewrite/refactor the methods to do less but I don’t think this team plans to do this for now. If I were the poor test engineer assigned to write automated unit tests for this, how would one go about this?

I refactored my test plans and created test Fragment(eg. login) in external jmx file so I can use in different test plans.

I used IncludeController in my test plan and refer this external Login Fragment file.

It works fine if I run jmeter gui, but as soon as I try to run in blazemeter cloud, it fails with error artifact not found. I tried downloading artifacts and external Fragment file is not there.

I came to know, IncludeController get verified before runtime, so there should be some other mechanism to upload these external test Fragment files.

I am sure relative paths for this Fragment jmx file is right as I am also using csv files and that is loading in blazemeter cloud.

Not sure if my approach of using tets Fragment is right?
Do I need to go to test in blazemeter and upload file manually?

For my test, I am using protractor. The test first opens an Angular page, do some actions and then open a nonangular site. For the nonangular site I did the following:
it(‘should login on BC’, function(){
browser.waitForAngularEnabled(false); // disable waiting to navigate to not Angular page
browser.get(‘non angularsite’);
element(by.id(‘UserName’)).sendKeys(‘user’);
element(by.id(‘Password’)).sendKeys(‘pwd’);
element(by.id(‘submitButton’)).click();
});

it(‘should confirm the quantity typed on BC’, function () {
browser.driver.manage().window().maximize();
browser.sleep(2000);
element(by.className(‘ms-list-itemLink’)).click();//click on search button
browser.sleep(2000);
browser.switchTo().frame(element(by.className(‘designer-client-frame’)).getWebElement());
element(by.css(‘.thm-cont-g0-bgcolor-1 > .icon-MoreEllipsis’)).click();
browser.sleep(1000);
element(by.linkText(‘BFTESTUSER’)).click();
browser.sleep(2000);

element(by.css(‘.ms-nav-contextmenu-trigger:nth-child(3)’)).click();//click on posting date
browser.sleep(3000);

When the automation reaches the
element(by.css(‘.ms-nav-contextmenu-trigger:nth-child(3)’)).click();//click on posting date

I got the following error:
Failed: element not interactable
(Session info: chrome=79.0.3945.130)
(Driver info: chromedriver=79.0.3945.16 (93fcc21110c10dbbd49bbff8f472335360e31d05-refs/branch-heads/3945@{#262}),platform=Windows NT 10.0.18362 x86_64)
Stack:
ElementNotVisibleError: element not interactable
(Session info: chrome=79.0.3945.130)
(Driver info: chromedriver=79.0.3945.16

I am trying to login to my application one by one using different credentials in robot framework-python-selenium but it is not working. Below is my code.
Please suggest.

Open Browser ${URL} chrome
Input Text id=username ${user}
Input Text id=password ${password}
${exp_row_count} get element count ${PATH_EXCEL}sheet1
${exp_row_count} evaluate ${exp_row_count}-1
For ${i} IN RANGE 1 ${exp_row_count}

*** Variables ***
${user} ${i}
${password} ${i}
${PATH_EXCEL} C:UsersTestLogin.xlsx
${i}

I use the keyword…
get date
But I have a date with the format like this
Sun May 11,2014 9:60 p.m.
I need to convert it in to this format 2014.05.11.09.60.60.321 I tried to put this yyyy.MM.dd.HH.mm.ss.ff in the format arg field… I tried to put the format in the variable to, but its not working ether 🙁
I dont know what to do to use the current datetime (stamp) as a variable!