Software Engineering

Could not load type ‘OpenQA.Selenium.Internal.IWrapsElement’ from assembly ‘WebDriver, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null’.
Stack Trace:
DefaultPageObjectMemberDecorator.CreateProxyObject(Type memberType, IElementLocator locator, IEnumerable`1 bys, Boolean cache)
DefaultPageObjectMemberDecorator.Decorate(MemberInfo member, IElementLocator locator)
PageFactory.InitElements(Object page, IElementLocator locator, IPageObjectMemberDecorator decorator)
PageFactory.InitElements(Object page, IElementLocator locator)
PageFactory.InitElements(ISearchContext driver, Object page)

chrome is loaded successfully but the error is in login
[SetUp]
public void Setup()
{
PropertiesCollection.Driver = new ChromeDriver();

PropertiesCollection.Driver.Navigate().GoToUrl(“http://XXX”);

}

[Test]
public void ExecuteTest()
{

//login using Page object Model
LoginPageObject pageLogin = new LoginPageObject();
DashboardPageObject Dashboard = pageLogin.Login();

Dashboard.NavigateToSecurity();

}

I have an iFrame in another iFrame, I´am able to switch to the parent iFrame and then to the child iFrame, but I´am just not able to switch back to the parent one. Is it even possible to switch up top to the parent one, as the driver is in the child iFrame?

I have created a POM framework using NUnit in C#. I have created Reporting.cs file which creates reports for the test in that class. How I can generate reports for all tests in different classes without rewriting the reporting code.

BaseTest
– References
– package
– config
– projects
|- project_name
|- pages
|- tests
|- utils
|- reporting.cs

In tests folder files with TestLoginModule.cs have functions

[Test]
public void TestFirst()
{
// test code
}
[Test]
public void TestSecond()
{
// test code
}

In tests folder files with TestDashboardModule.cs have functions

[Test]
public void TestThird()
{
// test code
}
[Test]
public void TestFourth()
{
// test code
}

In Reporting.cs file

[OneTimeSetUp]
public void BeforeClass()
{
// create a test report directory and attach reporter
extent = new ExtentReports();
var dir = AppDomain.CurrentDomain.BaseDirectory.Replace(“/bin/Debug”,””);
DirectoryInfo di = Directory.CreateDirectory(dir + “//Test_Execution_Reports”);
var htmlReporter = new ExtentHtmlReporter(dir + “//Test_Execution_Reports” + “//Automation_Report” + “.html”);
extent.AttachReporter(htmlReporter);
}

[TearDown]
public void AfterTest()
{
var status = TestContext.CurrentContext.Result.Outcome.Status;
var stacktrace = “” + TestContext.CurrentContext.Result.StackTrace + “”;
var errorMessage = TestContext.CurrentContext.Result.Message;
Status logstatus;

switch(status)
{
case TestStatus.Failed:
logstatus = Status.Fail;
test.Log(logstatus, “Test ended with” + logstatus + “-” + errorMessage);
test.Log(logstatus, “screenshot”);
break;
case TestStatus.Skipped:
logstatus = Status.Skip;
break;
default:
logstatus = Status.Pass;
break;
}

SB.Driver.Close();
SB.Driver.Quit();
}

[OneTimeTearDown]
public void AfterClass()
{
extent.Flush();
}

I want to call Reporting.cs OneTimeSetUp and TearDown after every Test in different files

I get the following error when I run the code
About to generate Cucumber report.
May 02, 2023 6:55:06 PM net.masterthought.cucumber.ReportBuilder generateErrorPage
WARNING: Unexpected error
net.masterthought.cucumber.ValidationException: No JSON report file was found!
at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:61)
at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:97)
at net.masterthought.cucumber.CucumberReportGeneratorMojo.execute(CucumberReportGeneratorMojo.java:236)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

CucumberOptions file
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(features=”src/test/java/features”,
plugin = {“pretty”, “json:target/reports/cucumber.json”,
“html:target/reports/cucumber.html”},
glue= {“stepDefs”},
stepNotifications = true,
monochrome = true
)
public class TestRunner {
}

pom file
<?xml version=”1.0″ encoding=”UTF-8″?>
<project xmlns=”http://maven.apache.org/POM/4.0.0″
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>Cucumber</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!– https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java –>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.4.0</version>
</dependency>

<!– https://mvnrepository.com/artifact/org.testng/testng –>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>

<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-java –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.8.1</version>
</dependency>

<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-junit –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>

<!– https://mvnrepository.com/artifact/org.assertj/assertj-core –>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<scope>test</scope>
</dependency>

<!– https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager –>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>

<!– https://mvnrepository.com/artifact/com.google.guava/guava –>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>

<!– https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java –>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.8.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>

<!– https://mvnrepository.com/artifact/org.slf4j/slf4j-simple –>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>

<!– https://mvnrepository.com/artifact/org.slf4j/slf4j-api –>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>

<!– https://mvnrepository.com/artifact/org.springframework/spring-core –>
<!– https://mvnrepository.com/artifact/org.springframework/spring-core –>

<!– https://mvnrepository.com/artifact/com.opencsv/opencsv –>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
</dependency>

<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>

<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<dependency>
<groupId>picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>1.2</version>
</dependency>

<!– https://mvnrepository.com/artifact/de.monochromata.cucumber/reporting-plugin –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-html –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.7</version>
</dependency>

<!– https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin –>

<!– https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin –>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</dependency>

<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-java8 –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-core –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>7.11.2</version>
</dependency>

<!– https://mvnrepository.com/artifact/net.masterthought/maven-cucumber-reporting –>
<!– https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting –>
<!– https://mvnrepository.com/artifact/com.aventstack/extentreports-cucumber4-adapter –>

<!– https://mvnrepository.com/artifact/com.aventstack/extentreports –>

<!– https://mvnrepository.com/artifact/com.relevantcodes/extentreports –>

<!– https://mvnrepository.com/artifact/net.masterthought/maven-cucumber-reporting –>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.7.5</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.7.5</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Cucumber</projectName>
<!– optional, per documentation set this to “true” to bypass generation of Cucumber Reports entirely, defaults to false if not specified –>
<skip>false</skip>
<!– output directory for the generated report –>
<outputDirectory>${project.build.directory}/reports</outputDirectory>
<!– optional, defaults to outputDirectory if not specified –>
<inputDirectory>${project.build.directory}/reports</inputDirectory>
<jsonFiles>
<!– supports wildcard or name pattern –>
<param>**/*.json</param>
</jsonFiles>
<!– optional, defaults to outputDirectory if not specified –>

<!– optional, set true to group features by its Ids –>
<mergeFeaturesById>false</mergeFeaturesById>
<!– optional, set true to get a final report with latest results of the same test from different test runs –>
<mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
<!– optional, set true to fail build on test failures –>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

I have a serial E2E test suite that’s growing and getting slower.
To solve this issue, I have to run the tests in parallel. But creating a user and all the required configurations is very complicated in this project.
Having one user per test is also not ideal, as some pieces of the configuration cost money.
So I was thinking of using something similar to Jenkins Lockable Resources or, where each user is a resource that can be “locked” per test and “unlocked” at the end.
Is there a simple API for achieving this? (Or another solution)

I am using Selenium Webdriver on Node.js with Cucumber.js.
I want to run the same test on multiple pages. In this case just checking for 404s in my footer.
My Cucumber .feature file looks like:
Feature: Check footer links

Scenario: Check for broken links in the footer section
Given I am checking the footer on the ‘<page>’ page
Then there should be no broken links in the footer on ‘<page>’ page

Examples:
| page |
| about-us |
| contact-us |
| products |

And in my steps.js file I have:
const { When, Then, Given, AfterAll } = require(‘@cucumber/cucumber’);
const assert = require(‘assert’);
const { Builder, By, until, Key, http } = require(‘selenium-webdriver’);
const firefox = require(‘selenium-webdriver/firefox’);
const XMLHttpRequest = require(‘xhr2’);
var {setDefaultTimeout} = require(‘@cucumber/cucumber’);
setDefaultTimeout(60 * 1000);

Given(‘I am checking the footers on the {string} page’, async function (string) {
this.driver = new Builder()
.forBrowser(‘firefox’)
.build();

this.driver.wait(until.elementLocated(By.className(‘logo-image’)));

await this.driver.get(‘https://www.some-site.com/’ + string);
});

Then(‘there should be no broken links in the footer on {string} page’, async function(string) {
var urlArr = [];
var footerLinks = await this.driver.findElements(By.css(‘.footer a’));
for (let i = 0; i < footerLinks.length; i++) {
var url = await footerLinks[i].getAttribute(“href”);
urlArr.push(url);
}

if (urlArr.length < 1) {
console.log(`Could not find any footer links on ${string} page`);
}
else {
for (let i = 0; i < urlArr.length; i++) {
var respStatus = await checkLink(urlArr[i]);
assert.ok(respStatus==200);
}
}
});

function checkLink(url) {
//Check link function returns status code….
}

This works fine, but for one thing: For each page that is tested a new instance of FireFox opens up.
I tried adding
After(async function() {
this.driver.quit();
});

To the end but this closes the session completely and the other tests fail after the first initial one is done.
Would anyone know how I could repeat the tests in the same browser instance?

we are using streaming platform and we need to test token expiration connected of social media accounts, can some body help me in this? like any tool or method will be helpful.
Thanks in advance.

The eCommerce industry is evolving rapidly with Gen AI at its core. By leveraging AI technology, businesses can generate unique content, personalize recommendations, and improve search functionalities. The blog discusses how it boosts customer experience and drives sales and operational efficiencies. Brands like eBay and Amazon are already seeing significant benefits. Gen AI’s role will become increasingly pivotal as the sector grows, transforming the shopping experience with advanced personalization, AR/VR interactions, and efficient supply chain management.
The post How Can Gen AI Improve eCommerce Customer Experience? first appeared on TestingXperts.

There is a testing techique that I often apply. I have recently decided to name it the First Hurdle Heuristic. The basic idea: get the product out of the starter’s blocks, and see how it performs given a relatively easy challenge. This heuristic can useful when you want to identify problems and risks immediately, or to determine whether a product might not be ready for use or for deeper testing. … Read more

Test Guild – Automation Testing Tools Community
Mastering AI in Test Automation: Expert Tips!
Over the last couple of years, many of my podcast guests who work in the testing industry have spoken about the rapid adoption of AI within their software development teams. During a recent webinar/podcast I hosted with automation testing industry veterans Tal Barmeir and Guy Arieli of Blink.io., for instance, they dropped some real-world knowledge
You’re reading Mastering AI in Test Automation: Expert Tips!, originally posted on Test Guild – Automation Testing Tools Community – and copyrighted by Joe Colantonio

Facing issue to read content after clicking an element in Selenium. I have tried with below code:

if(webElement2.isDisplayed()) {
webElement.explicitWaitToClickElement(4,webElement);
webElement2.click();
}

String tagContent = (String) ((JavascriptExecutor)
BrowserUtilities.getDriver()).executeScript(“return arguments[0].innerText;”, webElement2);

I am trying to get the name and the price information from this website with XPath. When i write my XPath expression down in the search bar it locates correctly in the chrome. But in VSC it doesn’t work. I get nameHtml is null error. This is the only element that has style__Text-sc-__sc-1nwjacj-0 iwTTHJ sc-dd9e2587-8 dsYcan class. Is there a problem with my expression or the code ?
Thanks

my code:
public class Main {

public static HtmlPage getDocument(String url) {
HtmlPage page = null;
try (final WebClient webClient = new WebClient()) {
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);
page = webClient.getPage(url);
} catch (IOException e) {
e.printStackTrace();
}
return page;
}

public static void main(String[] args) throws IOException {

WebClient webClient = new WebClient();
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);

HtmlPage page = getDocument(“https://getir.com/en/category/fruits-veg-tBYm30SlS9/”);
HtmlElement nameHtml = page.getFirstByXPath(“//div[@class = ‘style__Text-sc-__sc-1nwjacj-0 iwTTHJ sc-dd9e2587-8 dsYcan’]”);

System.out.println(nameHtml.asNormalizedText());}

Workload Automation (WLA) offers a unified solution for managing complex, repetitive tasks, providing significant benefits to IT teams and businesses by improving efficiency and operational accuracy. In this article, we will learn what is workload automation, its advantages, disadvantages, and the following. What is Workload Automation (WLA) Workload Automation (WLA) is the process of using…
The post What is Workload Automation? Detailed Tutorial appeared first on Software Testing Material.

I need to automate a login which uses a fido token. No person can be behind the screen as it is supposed to be automated. I can build a small device which would move the “finger” up and down. My questions is: What can I use to disguise a human finger?

With same code I have tried scrolling, firstly I scrolled to bottom then top and then to element so that element can get loaded properly even though sometimes testcases are failing due to scrolling
public void pageScroller() {
try {
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript(“window.scrollTo(0, document.body.scrollHeight)”);
Thread.sleep(2000);
executor.executeScript(“window.scrollTo(0, 0)”);
Thread.sleep(2000);
}
catch(Exception e) {
test.log(Status.FAIL, e);
}
}“`

//Tried below two functions for scrolling

“`private void scrollToElement(WebElement articleSection2) {
// TODO Auto-generated method stub
try {
((JavascriptExecutor) driver).executeScript(“arguments[0].scrollIntoView();”, getWebElement(articleSectionStr));
} catch (Exception e) {
e.printStackTrace();
}
}

public void scrollToSection(WebElement element) {
try {
JavascriptExecutor executor = (JavascriptExecutor) driver;
int loc = element.getLocation().y;
executor.executeScript(“window.scrollTo(0, ” + (loc – 150) + “);”);
} catch (Exception exception) {
exception.printStackTrace();
}
}