Guys First of all I am totally new for Selenium.
I am having a automation project. In my project, I am creating a screenshot function to take screenshots of my event which I have created for my testcases. Now if my test cases passes then all screenshot should move to Pass folder, else fail folder.
I would like to know how to detect that my test case pass?
I know Nunit detects but I wanted to program it so that I cam place my screenshot as well as log file to pass or fail folder.
Program in C#
Selenium
Nunit to run my test case.
I think you meant was this. But there is work around for this. You need to add your code accordingly.
if (TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Failure))
{
IntegrationTest.WriteInLog("FAILS");
}
else if (TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Success))
{
IntegrationTest.WriteInLog("SUCESS");
}
Check status property and compare it with TestStatus enum at teardown method.
NUnit2:
TestContext.CurrentContext.Result.Status
NUnit3:
TestContext.CurrentContext.Result.Outcome.Status
Related
I have created a unit test project with Selenium to perform some UI actions. In one of page i need to upload file from local machine, and for that i am using SendKey method available in c# but that is not consistent so i thought if we can add a small recorded coded UI method which would just do windows interaction like select file from window control. I browse through MSDN and tried all links but its not happening. Please help me in this regards
say I have created a Unit test Project "Test" and inside that created a Unit Test class added selenium web driver references and inside it a Test Method in which i launched the browser and reached till the point where i need to upload file.
Now I added a coded UI test file and recorded the uploading the file part in CodeUITestMethod1() in new class CodedUITest.
Now when i try to call codedUITestMethod1() from my first test class its giving errors like "PlayBack.dll "or "UITest.dll" or some other Dll could not be Found. But i have added all the coded UI and these dlls and i ensure that i call PlayBack.Initilize() before codedUITestMethod1() is called but everytime i get some errors at PlayBack.Initilize() method.
I have taken refrence from follwing links :
https://blogs.msdn.microsoft.com/gautamg/2010/03/30/how-to-get-uitesting-methods-working-outside-the-testmethod-of-coded-ui-test/
http://blogs.microsoft.co.il/shair/2010/07/15/running-codedui-test-from-another-application/
I have used visual studio 2013 for this work . Pleas Help
I am new to Protractor. Can anyone tell me how can we use Actions like mouse over,drag and drop(like Actions in Selenium) in Protractor. I need just a syntax or a code snippet.
It is actually there, inside the Protractor API documentation: .actions():
browser.actions().
mouseDown(element1).
mouseMove(element2).
mouseUp().
perform();
A common problem is to forget calling perform() at the end which may results into it doing nothing. We actually had a weird test that had an action chain without the perform() and, because of the incorrect expectation the test just passed. You can catch these types of problems statically now, with eslint-plugin-protractor (shameless self-promotion).
I'm using Behat with Mink.
I would like one of my step definitions to act differently depending on which driver is running.
Ideally, my code would look something like this
public function stepDefinition(){
if($this->getSession()->getDriver()->name == 'goutte'){
//code to run if using goutte
}else{
//code to run if selenium is running
}
}
So, though a little bit of delving into the code meant that I've found a solution to this. And seen as google was no help, hopefully this will be of help to someone else.
My code now looks like this
if( $this->getSession()->getDriver() instanceof Behat\Mink\Driver\Selenium2Driver){
// Selenium Code
}else{
//Goutte Code
}
I've just grabbed the driver object and have checked which driver class it's an extension of, simple.
Now I can run the same step definition if the #javascript tag is or isn't before my scenario.
I've install PHPUnit3.6.2 and tried to run simple test.
If test Successful, there are no problems: phpunit reporting that test is OK.
But if there any error in test, PHPUnit reporting NOTHING! No failure and error text, no line in test.php, just empty line.
If it can helps: in browser code ends with getLocation() method. But I didnt use such method in my test.
why is this happening?
Also I should add: if in test use some element, wich not present on web page (for example button with wrong x-path). And there is action with this button in test:
$this->clickAt("wrong x-path");
phpunit doesn't show error report too. It continues to run. Looks like it found this button and clicked it. But there is NO such button on page.
No errors, no failures, test doesn't stop...
You are alking about Selenium testing. getLocation() is called by PHPUnit when formatting the failure report (to display the URL on which the failure occurred). You should try some simple (non-Selenium) PHPUnit tests to see if failure/error reporting works there, so you can narrow it down to Selenium or PHPUnit itself.
How do you guys run single tests with IDEA's TestNG plugin? I tried creating a focus group, but it seems the TestNG plugin does not resolve dependencies to other tests automatically. Even when I comment out dependsOnMethods, it seems #BeforeMethod is not run.
Advice is greatly appreciated,
Robin
If you mean a single test method inside a test class there is a right-click option called Run "testMethod" where testMethod is the actual method name.
The short cut is ctrl+shift+F10.
If you put the cursor between methods (even outside the javadoc) or outside the entire class it will test all methods in that file.
Bring the class into focus in the editor, and then simply right-click, select run?