atata | C # /.NET test automation framework for web | Functional Testing library
kandi X-RAY | atata Summary
Support
Quality
Security
License
Reuse
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
atata Key Features
atata Examples and Code Snippets
Trending Discussions on atata
in Atata
Trending Discussions on atata
QUESTION
I am trying to implement simple drag an drop operation on this site with Selenium examples: https://demoqa.com/droppable. How it looks like:
And seems, my implementation of drag and drop with Atata doesn't work. I got no error, but nothing actually happens.
My implementation:
Page Object:
{
using _ = DemoQAInteractionsPage;
[Url("interaction")]
[WaitForDocumentReadyState]
public class DemoQAInteractionsPage : Page<_>
{
[FindById("item-3")]
[ScrollsUsingScript]
public Control<_> DroppableMenu { get; private set; }
[FindById]
[DragsAndDropsUsingActions]
[WaitUntilEnabled]
public Control<_> Draggable { get; private set; }
[FindById]
[DragsAndDropsUsingActions]
[WaitUntilEnabled]
public Control<_> Droppable { get; private set; }
[FindByContent("Dropped!")]
[WaitUntilEnabled]
public Control<_> DroppedMessage { get; private set; }
}
}
Test:
[Test]
public void DemoQADragAndDropTest()
{
Go.To()
.GoToInteractions();
Go.To(navigate: false)
.DroppableMenu.ScrollTo()
.DroppableMenu.Click()
.Draggable.DragAndDropTo(x => x.Droppable);
}
I know about plain Selenium implementation, but would prefer Atata API for this. Could you, please, suggest something?
Update: For some reason, this approach is working:
public _ PerformDragAndDrop()
{
IWebElement target = Droppable.GetScope();
IWebElement source = Draggable.GetScope();
Actions actions = new Actions(Driver);
actions.ClickAndHold(source);
actions.MoveToElement(target);
actions.Perform();
actions.Release(target);
actions.Perform();
return this;
}
I've read about this issue, maybe, it's related to chromedriver. Anyway, this could be used as a workaround, using Atata API still would be preferable. Maybe, there is some well-known bug in chromedriver related to this issue?
ANSWER
Answered 2022-Feb-18 at 10:35Although the test works for me, you can create your drag & drop behavior class:
public class DragsAndDropsUsingActionsStepByStepAttribute : DragAndDropBehaviorAttribute
{
public override void Execute(IControl component, IControl target)
{
IWebElement sourceElement = component.Scope;
IWebElement targetElement = component.Scope;
Actions actions = new Actions(component.Context.Driver);
actions.ClickAndHold(sourceElement);
actions.MoveToElement(targetElement);
actions.Perform();
actions.Release(targetElement);
actions.Perform();
}
}
And apply it to Draggable
property:
[FindById]
[DragsAndDropsUsingActionsStepByStep]
public Control<_> Draggable { get; private set; }
QUESTION
I'm testing some ways to identify anagrams and I found a situation that got me off guard. I found out that it's possible to do using XOR so I was testing it using the XOR operator. Here's my code:
public static void main(String[] args) {
// TODO code application logic here
String s1 = "pe";
String s2 = "ep";
System.out.println(isAnagram(s1, s2));
}
private static boolean isAnagram(String firstString, String secondString)
{
int control = 0;
System.out.println("Comparing: " + firstString + " and " + secondString);
for (int i = 0; i < firstString.length(); i++) {
control = control ^ firstString.charAt(i);
}
for (int i = 0; i < secondString.length(); i++) {
control = control ^ secondString.charAt(i);
}
System.out.println("Control: " + control);
return (control == 0);
}
When the 2 strings have the same sets of characters, even when they are not in the same order the control variable is 0 returning true to anagram. However, when the 2 strings are different the control has a value > 0 returning false to anagram. I tried using many words and most of them worked, but for some reason it often has some strange situations where, for example, "v" and "ils" return true to anagram or "tat" and "atata" returns true as well.
I would like to understand why it happens and what should I do so this situations doesn't show up anymore.
ANSWER
Answered 2022-Feb-17 at 17:37Simply, the algorithm you are using is not going to work. Since XOR is associative and commutative (like, for example, addition), XORing together all the characters in a string produces the same value regardless of the order in which you do the XORs. Similarly, you get the same sum of the values in an array regardless of the order in which you do the additions.
But, also like addition, XOR throws away information. You cannot go backwards from the result to the original values: 1+3 = 2+2 = 0+4
. And similarly with XOR: 1^3 = 6^4 = 0^2
.
One particular feature of XOR is that a ^ a = 0
for any a; also a ^ 0 = a
. (These statements are related.) So you can always just remove pairs of identical characters; the XOR combination of atata
is the same as the combination of tat
and also the same as a
.
QUESTION
Hi,
I use Atata framework with ExtentReports, based on this project: https://github.com/atata-framework/atata-samples/tree/master/ExtentReports
Now I want switch from fluent context build to json config. My fluent context build looks like:
AtataContext.GlobalConfiguration
.UseChrome()
.WithArguments("--start-maximized")
.WithLocalDriverPath()
.WithFixOfCommandExecutionDelay()
.UseCulture("en-US")
.UseAllNUnitFeatures()
.AddDebugLogging()
.AddScreenshotFileSaving()
.WithArtifactsFolderPath()
.AddLogConsumer(new ExtentLogConsumer())
.WithMinLevel(LogLevel.Info)
.EventSubscriptions.Add(new ExtentScreenshotFileEventHandler());
AtataContext.GlobalConfiguration.AutoSetUpDriverToUse();
I can implement via json config almost all, except this line:
.EventSubscriptions.Add(new ExtentScreenshotFileEventHandler());
My config:
{
"driver": {
"type": "chrome",
"alias": "chrome",
"options": {
"arguments": [ "start-maximized" ],
"userProfilePreferences": {
"download.default_directory": "{artifacts}"
}
}
},
"culture": "en-US",
"useAllNUnitFeatures": true,
"logConsumers": [
{
"type": "nlog-file",
"folderPath": "{artifacts}",
"minLevel": "Debug"
},
{
"type": "AtataUITests1.Core.Reporting.ExtentLogConsumer, AtataUITests1",
"minLevel": "Info"
}
],
"screenshotConsumers": [
{
"type": "file",
"folderPath": "{artifacts}"
}
]
}
When I try to add new screenshotConsumer
to json:
"screenshotConsumers": [
{
"type": "file",
"folderPath": "{artifacts}"
},
{
"type": "AtataUITests1.Core.Reporting.ExtentScreenshotFileEventHandler, AtataUITests1"
}
]
it shows error:
System.InvalidCastException : Unable to cast object of type 'AtataUITests1.Core.Reporting.ExtentScreenshotFileEventHandler' to type 'Atata.IScreenshotConsumer'.
My question is: is it possible to pass this custom screenshot consumer via json?
Thanks
ANSWER
Answered 2022-Feb-02 at 15:55ExtentScreenshotFileEventHandler
is not a screenshot consumer but an event handler. So it should be placed in "eventSubscriptions" section as below:
"eventSubscriptions": [
{
"handlerType": "AtataUITests1.Core.Reporting.ExtentScreenshotFileEventHandler, AtataUITests1"
}
]
There is also an example on Atata.Configuration.Json / JSON Schema section.
QUESTION
I have a 3X3 data frame (df)
whose columns are "observation" and "features". Each cell of "features" columns has many lists of dictionaries in them.
I would like to write a loop which will go over each cells of "features" columns and will count the number of unique two-digit categories, simultaneously these counted numbers will be put to another data frame which will have two columns: "Categories" (such as "02 Pppppppp") which will give the name of two-digit categories and their counted numbers in "Count" column.
observation = [1, 2, 3]
features = [
"""[[{'id': '2211', 'name': '11 Mmmmm'},
{'id': '3142', 'name': '1112 Mmmmm Ooooo'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2401', 'name': '0204 Pppppppp Mmmmm'},
{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'},
{'id': '2389', 'name': '0202 Pppppppp Atata'}],
[{'id': '2211', 'name': '11 Mmmmm'},
{'id': '3053', 'name': '1103 Mmmmm Sssssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2211', 'name': '11 Mmmmm'},
{'id': '2206', 'name': '06 Bbbbbb'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}],
[{'id': '2202', 'name': '02 Pppppppp '},
{'id': '2421', 'name': '0299 Pppppppp Sssss'}]]""",
"""[[{'id': '2581', 'name': '0601 Bbbbbb Cbcbcb'},
{'id': '2206', 'name': '06 Bbbbbb'}],
[{'id': '2666', 'name': '0699 Other Bbbbbb'},
{'id': '2486', 'name': '0399 Other Kkkkkk '},
{'id': '2203', 'name': '03 Kkkkkk '},
{'id': '2620', 'name': '0604 Genetics'},
{'id': '2206', 'name': '06 Bbbbbb'}],
[{'id': '2581', 'name': '0601 Bbbbbb Cbcbcb'},
{'id': '2206', 'name': '06 Bbbbbb'}],
[{'id': '2211', 'name': '11 Mmmmm'}],
[{'id': '2581', 'name': '0601 Bbbbbb Cbcbcb'},
{'id': '2206', 'name': '06 Bbbbbb'}],
[{'id': '2921', 'name': '0912 Wwwww Apapa'},
{'id': '2209', 'name': '09 Wwwww '},
{'id': '2844', 'name': '0904 Wwwww Enenen'}]]""",
"""[[{'id': '2921', 'name': '0912 Wwwww Apapa'},
{'id': '2209', 'name': '09 Wwwww '},
{'id': '2203', 'name': '03 Kkkkkk '},
{'id': '2471', 'name': '0306 Kkkkkk Chch'}],
[{'id': '2203', 'name': '03 Kkkkkk '},
{'id': '2471', 'name': '0306 Kkkkkk Chch'}]]""",
]
d = {"Observations": observation, "Features": features}
df = pd.DataFrame(data=d)
ANSWER
Answered 2022-Jan-02 at 18:52You could try to :
- find and parse all the string dictionaries in
features
with the help of Python standard library re and ast modules, - count unique values and make a dataframe of them,
- finally, exclude categories which names do not begin with two digits using Pandas str.match method.
Like this:
import ast
import re
import pandas as pd
records = [
ast.literal_eval(record)
for string in features
for record in re.findall(r"{.+\W}", string)
]
df = pd.DataFrame(records)
new_df = df["name"].value_counts().to_frame().reset_index(drop=False)
new_df.columns = ["Categories", "Count"]
new_df = new_df.loc[new_df["Categories"].str.match(r"\d{2}\s"), :].reset_index(
drop=True
)
print(new_df)
# Ouputs
Categories Count
0 02 Pppppppp 10
1 06 Bbbbbb 5
2 11 Mmmmm 4
3 03 Kkkkkk 3
4 09 Wwwww 2
QUESTION
Here's the content of my GlobalSetup - occasionally when I run, the call to AutoSetUpConfiguredDrivers throws an exception:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'
EdgeOptions Options = new EdgeOptions();
Options.AddArgument("window-size=1600,900");
Options.AcceptInsecureCertificates = true;
EdgeOptions HeadlessOptions = new EdgeOptions();
HeadlessOptions.AddArgument("headless");
HeadlessOptions.AddArgument("window-size=1600,900");
HeadlessOptions.AcceptInsecureCertificates = true;
AtataContext.GlobalConfiguration
.UseChrome().WithArguments("ignore-certificate-errors", "window-size=1600,900")
.UseChrome().WithArguments("ignore-certificate-errors", "window-size=1600,900", "headless").WithAlias("chrome-headless")
.UseFirefox().WithGlobalCapability("acceptInsecureCerts", true).WithArguments("--width=1600").WithArguments("--height=900")
.UseFirefox().WithGlobalCapability("acceptInsecureCerts", true).WithArguments("--width=1600").WithArguments("--height=900").WithArguments("--headless").WithAlias("firefox-headless")
.UseEdge().WithOptions(Options)
.UseEdge().WithOptions(HeadlessOptions).WithAlias("edge-headless")
.UseCulture("en-US")
.AddScreenshotFileSaving()
.UseNUnitTestName()
.UseNUnitTestSuiteName()
.UseNUnitTestSuiteType()
.UseNUnitAssertionExceptionType()
.UseNUnitAggregateAssertionStrategy()
.UseNUnitWarningReportStrategy()
.AddNUnitTestContextLogging()
.WithMinLevel(LogLevel.Info)
.WithoutSectionFinish()
.LogNUnitError()
.TakeScreenshotOnNUnitError("Test Failure")
.OnCleanUpAddArtifactsToNUnitTestContext();
//DriverSetup.AutoSetUp(BrowserNames.Edge);
AtataContext.GlobalConfiguration.AutoSetUpConfiguredDrivers();
If I uncomment the DriverSetup line, I never see the error. Using Atata 1.13.0, Atata.WebDriverSetup 1.2.0 and Selenium 4.0.0 - any ideas?
--As requested - here's the stack trace:
at System.ThrowHelper.ThrowArgumentOutOfRange_IndexException()
at System.Collections.Generic.List`1.RemoveAt(Int32 index)
at System.Collections.Generic.List`1.Remove(T item)
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.SetUp()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.d__11.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Atata.WebDriverSetup.DriverSetup.d__26.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Atata.WebDriverSetup.DriverSetup.d__28.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Atata.WebDriverSetup.DriverSetup.d__30.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Atata.WebDriverSetup.DriverSetup.AutoSetUpSafely(IEnumerable`1 browserNames)
at Atata.MethodInfoExtensions.InvokeStaticAsLambda(MethodInfo method, Object[] args)
at Atata.AtataContextBuilder.InvokeAutoSetUpSafelyMethodOfDriverSetup(IEnumerable`1 browserNames)
at Atata.AtataContextBuilder.AutoSetUpConfiguredDrivers()
at Atata.Config.SetUpFixture.GlobalSetUp() in C:\Source\fs.automation\Atata.Config\Atata.Config\SetUpFixture.cs:line 45
ANSWER
Answered 2021-Oct-26 at 14:28There was a thread synchronization bug in Atata.WebDriverSetup v1.2.0. Thanks for reporting it. It should be fixed now in Atata.WebDriverSetup v1.2.1. Please update the package and verify that this error doesn't reproduce.
QUESTION
in Atata
I have this table cell on my page:
Some Text
random description
I'd like to come up with a way to validate the text after the br and have it return that as Text
so I can use the atata asserts (like Should.Equal("random description")) - separately from the text inside the but so far have been unable to do anything more than get that text as a string by getting the td via xpath and .Split("\r\n") it's Value - is there a way to get just this text?
ANSWER
Answered 2021-Jul-28 at 07:48You can do that by adding [ContentSource(ContentSource.LastChildTextNode)]
attribute to your text control.
Alternatively, you can invoke TextControl.GetContent(ContentSource.LastChildTextNode)
method.
QUESTION
It appears that the version of Selenium included with Atata does not support the EdgeOption "UseChromium", and when I try to use the Edge Driver, the test run fails unless I rename the driver in the bin\Debug\netcoreapp2.1\drivers\edge\91.0.864.41 folder from "msedgedriver.exe" to "MicrosoftWebDriver.exe", which leads me to believe it's trying to run the old non-chromium Edge - is there some way to get this working?
ANSWER
Answered 2021-Jun-13 at 11:29In order to use Chromium Edge with Atata:
Update
Selenium.WebDriver
package to4.0.0-beta2
version.Change Atata configuration to:
AtataContext.GlobalConfiguration
.UseDriver(() =>
{
EdgeOptions options = new EdgeOptions
{
UseChromium = true
};
// Headless options:
//options.AddArguments("headless", "disable-gpu", "window-size=1024,768");
return new EdgeDriver(options);
})
Atata Samples / Using Headless Edge sample might also help.
QUESTION
I'm currently working with the Atata framework and using a Kendo grid. What I'm trying to achieve is getting an IEnumerable or a collection containing all the values in a column. The kendo grid is defined as below:
public KendoGrid TransactionGroupsGrid { get; private set; }
public class TransactionGroupsRow : KendoGridRow<_>
{
[FindByColumnHeader("Group Name")]
public Link<_> GroupName { get; private set; }
}
I not only want a collection of all the links GroupName, I specifically want the text component of them i.e. what the link would read like on the screen.
So in this example I would want an IEnumerable containing "002999" and "003999".
Let me know if I need to provide additional detail. Thanks in advance!
ANSWER
Answered 2021-Apr-23 at 09:16There are 2 ways to do that.
Use
SelectData
method. It works quite fast for list of items with count <= 50.
// Just get all items:
IEnumerable groupNames = page.TransactionGroupsGrid.Rows
.SelectData(x => x.GroupName.Content.Value).Value;
// Assert items:
page.TransactionGroupsGrid.Rows
.SelectData(x => x.GroupName.Content.Value).Should.Contain("002999", "003999");
The faster way is using SelectContentsByExtraXPath
method. This one will work very fast even for a table with 1000 rows. But you need to specify a relative XPath to the table cell td
element inside a row tr
element. This can also be extracted to the page object class as a method.
// Just get all items:
IEnumerable groupNames = page.TransactionGroupsGrid.Rows
.SelectContentsByExtraXPath("td[1]", "Group Names").Value;
// Assert items:
page.TransactionGroupsGrid.Rows
.SelectContentsByExtraXPath("td[1]", "Group Names").Should.Contain("002999", "003999");
You can also check Performance Practices for ControlList Atata sample project.
QUESTION
Thank you for taking the time to read my question! Most likely I formulated my question wrong, so sorry for confusing you already. It also might be a basic Javascript question for some of you, but I can not wrap my head around it. I will try my best explaining as to what I am doing.
My data looks like this:
{
"data": {
"textvulnerabilities": [
{
"countryname": "Timor-Leste",
"impacts": "Increase in rainfall intensity may lead to increase in flood occurrence in new areas.\n\tIncrease in floods may lead to extensive damage to existing water infrastructures and roads.\n\tIncrease in flood and drought occurrence will lead to exacerbation of current food security problems.\n\tAs a consequence of increased precipitation and extreme events, increase in landslides, wild fires, and deforestation will occur.\n\tIncreased rain variability and drought occurrence will lead to extended incidence of pest and crop diseases, as well as vector-borne diseases and increase in coastal vulnerability.",
"hazardid": 242
},
{
"countryname": "Tonga",
"impacts": "A current lack of effective or efficient water storage infrastructure endangers agricultural production and water quality and quantity for human consumption in Tonga. The likelihood of increased sedimentation and salt water intrusion under future sea level rise and extended drought conditions could cripple existing water infrastructure.\n\tHurricane-strength cyclones, or those with winds stronger than 63 knots or 117 km/hr, have increased systematically in the southwest Pacific and the region now experiences on average four hurricane-strength cyclones a year. Increased cyclone intensity under possibly future climate change remains a matter of debate among the climate science community, however likely trends of drier and warmer climate and an increase in sea surface temperatures these disasters are likely to increase.\n\tA general increase in tropical cyclone intensity (lower central pressures, stronger winds and higher peak and mean precipitation intensities) appears likely, as does an eastward extension in the area of formation. Early Warning Systems need to be expanded and improved and better climate modeling available to prepare for impending storms and their correlative effects.\n\tFuture climate is expected to become more El-Nino like, resulting in more droughts in the southern Pacific and more rain and consequent floods in the equatorial Pacific and Cyclones are expected to increase in intensity by about 520 percent. Risk management of natural hazards (RMNH) such as Planting mangroves to stabilize land against erosion and managing.\n\tExpected sea level rise may completely inundate the villages of Villages of Kanokupolu-Haakili-Ahau, Nukuleka-Talafoou-Navutoka-Manuka and all the areas East of Sopu and Siesia at Nukunukumotu Island and Atata Island. A long lasting and effective foreshore protection seawall similar to the present Nukualofa foreshore protection would minimize and flooding in these and other low-lying areas.",
"hazardid": 245
},
]
}
}
My database contains about 251 countries and I am looping over every single one of them like this :
const CountryHazardText = ({ hazardid }) => {
const { data, loading, error } = useQuery(GET_HAZARD_TEXT, {
variables: { hazardid: hazardid },
});
const initialCountry = data ? data.textvulnerabilities : [];
const singleCountry = initialCountry;
{
return (
{singleCountry ? (
singleCountry.map((country, index) => {
return (
{country.impacts}
);
})
) : (
No impacts found
)}
);
}
};
Which works fine. But as you can see, the impacts are quite large and they become difficult for users to read. Luckily there is a "\n" inside the object, so I assume that based on this I would be able to create a for-loop, that whenever it encounters a "\n", it would create a ListItem out of the text, right?
I tried formulating this, but came as close as this, then the logic in my head broke:
{country.impacts ? (country.impacts.map ((impact, index) =>
{
return (
// For every encounter with a "\n " inside country.impacts create a new listitem:
-
)
})}
This is obv incorrect, but I don't understand how I would do this. It would also be nice if someone would explain the exact terms as to what I am doing. As far as I understand, I am trying to map the content of an item in an array, right?
Thanks a lot for being here!
Bridler
ANSWER
Answered 2021-Feb-19 at 09:42here is how you can split a text into a list
impact.split("\n")
you can split by any key you want, in the above case it's \n
QUESTION
I am trying to open browser, run several tests and close browser. My problem is that browser stays open after running all tests. What is the correct way of closing browser? If I put [Setup] and [TearDown] attributes to open and close browser in each test - browser is opened and closed, but if I put [OneTimeSetup] and [OneTimeTearDown] attributes - browser stays opened.
using Atata;
using NUnit.Framework;
namespace UITests
{
[TestFixture]
public class UITestFixture
{
[OneTimeSetUp]
public void SetUp()
{
//Open Chrome
AtataContext.Configure().
ApplyJsonConfig("Atata.json").
Build();
}
[OneTimeTearDown]
public void TearDown()
{
AtataContext.Current?.CleanUp();
}
}
}
using Atata;
using NUnit.Framework;
namespace UITests
{
class Tests : UITestFixture
{
[Test]
public void PositiveTest()
{
Go.To().ItemToVerify1.Should.Equal("2,006.59");
}
[Test]
public void NegativeTest()
{
Go.To().ItemToVerify2.Should.Equal("2,006.59");
}
}
}
using Atata;
namespace UITestFixture
{
using _ = OverallViewPage;
public class OverallViewPage : Page<_>
{
[FindByXPath("/html/body/div[2]/app-root/pnl/div/div/pnl-total/pnl-total-grid/main-grid/div/div/div/main-grid-row/div[2]/main-grid-row/div[4]/div[3]/div/span")]
public Link<_> ItemToVerify1 { get; private set; }
[FindByXPath("/html/body/div[2]/app-root/pnl/div/div/pnl-total/pnl-total-grid/main-grid/div/div/div/main-grid-row/div[2]/main-grid-row/div[4]/div[2]/div/span")]
public Link<_> ItemToVerify2 { get; private set; }
}
}
ANSWER
Answered 2020-Sep-28 at 15:39It is possible but not correct to use the same AtataContext
in different tests. Separate AtataContext
should be created per each UI test, as AtataContext
also collects log during test execution. But you can reuse the same web driver instance by different tests by passing already created instance of RemoteWebDriver
to each AtataContextBuilder
.
Check out the sources of Fixture Reusing Driver Atata sample project.
Basically you need to enhance base test fixture class like below:
using Atata;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
namespace AtataSamples.FixtureReusingDriver
{
[TestFixture]
public class UITestFixture
{
protected virtual bool ReuseDriver => false;
protected RemoteWebDriver PreservedDriver { get; private set; }
[OneTimeSetUp]
public void SetUpFixture()
{
if (ReuseDriver)
PreservedDriver = AtataContext.GlobalConfiguration.BuildingContext.DriverFactoryToUse.Create();
}
[SetUp]
public void SetUp()
{
AtataContextBuilder contextBuilder = AtataContext.Configure();
if (ReuseDriver && PreservedDriver != null)
contextBuilder = contextBuilder.UseDriver(PreservedDriver);
contextBuilder.Build();
}
[TearDown]
public void TearDown()
{
AtataContext.Current?.CleanUp(!ReuseDriver);
}
[OneTimeTearDown]
public void TearDownFixture()
{
if (PreservedDriver != null)
{
PreservedDriver.Dispose();
PreservedDriver = null;
}
}
}
}
Then in fixture classes where you need to use the same driver instance by all tests enable ReuseDriver
property:
public class SomeTests : UITestFixture
{
protected override bool ReuseDriver => true;
[Test]
public void SomeTest()
{
//...
}
}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install atata
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page