automated-tests

Check if test failed in afterEach of Jest

﹥>﹥吖頭↗ 提交于 2020-01-14 10:06:36
问题 When one of my Jest tests fails I want to store a screenshot, but only when it fails. Here is a piece of my test code as an example, the !passed part in the afterEach is not working. describe('Page', () => { it('should contain Text in the header', async () => { // Arrange const page = new Page(driver); // Act await page.open(); // Assert expect(await page.getHeaderText()).toBe('Something'); }); afterEach(async () => { if (!passed) takeScreenshot(); await driver.quit(); }); }); With jasmine I

Maintain context between unit test methods in VS Test Project

五迷三道 提交于 2020-01-14 07:53:06
问题 I want to run the following unit tests, in order: Create new customer with a random number for name, password etc. Retrieve the just created customer and assert that its properties contain the same random number Call the ForgotPassword function on same user, with the same random number for user name As seen clearly, I need to generate a random number once, and share it across 3 test methods. I cannot seem to find a way to do that. I thought of using the TestContext object, but that gets

NightmareJS multiple reports from same test

三世轮回 提交于 2020-01-14 06:37:10
问题 Thanks to @pipo_dev I was able to solve an issue I was having with multiple evaluations in NightmareJS, one thing that I would like to know is if I can provide multiple reports for the same test, take the following as an example: describe('test google search results', function() { this.timeout(15000); it('should find the nightmare github link first', function(done) { var nightmare = Nightmare({show: true}) nightmare .goto('http://google.com') .wait(1000) .type('form[action*="/search"] [name=q

Would like to create a timer in Selenium and do some action until reach a defined period of time

无人久伴 提交于 2020-01-14 04:27:05
问题 I'm trying to keep executing an action in a loop until reach a specific period of time. Example: execute something like sysout for 10 seconds, then stop the execution. I have seen some information about Timer class but was not useful so far. In the code below, trying the keep scrolling down (because it is a infinite scroll) the page until reach some time in seconds. JavascriptExecutor js = (JavascriptExecutor) driver; while(countdown <= 15) { //countdown should be my defined limit of time js

How to run findbug on the test code

喜欢而已 提交于 2020-01-14 02:33:47
问题 I have a test only maven project. The folder structure is as follows project-root |_ src | |_ main | | |_ java | | |_ resources | |_ test | |_ java | |_ resources |_ .classpath |_ .project When I run the findbug plugin It do not pick the classes under test. Is there a way we can instrument the test code which is under test, to find bug? My maven pon has the below plugin under the reporting section <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven

Get Type in Robot Framework

半世苍凉 提交于 2020-01-14 02:30:07
问题 Could you tell me about how to get the variable type in Robot Framework. ${ABC} Set Variable Test ${XYZ} Set Variable 1233 Remark: Get the variable Type such as string, int get ${ABC} type = string get ${XYZ} type = int 回答1: This is what I use: ${type} = Evaluate type($temp).__name__ Note: it's good to have global string/int/float/list/dict/... examples for comparison than hard-coding the type values as they might differ depending on build. 回答2: You can do e.g. this: ${type_ABC} Evaluate type

Enabling a disabled field using javascript executor for selenium webdriver ruby binding script

房东的猫 提交于 2020-01-13 14:47:50
问题 I am writing following Ruby code in Selenium Webdriver script to enable a disabled field on UI through Javascript executor. browser.execute_script("browser.find_element(:xpath,'/html/body/div[5]/div/div[3]/div[2]/div[2]/div/div/div/div/div/div/input'.disabled = false") But facing, `handleEvaluateEvent': syntax error (Selenium::WebDriver::Error::JavascriptError) What could be wrong with my syntax? Any Help will be appreciated. Thanks! Abhishek 回答1: Problem The problem with the line: browser

Acceptance testing preloading of data into GAE dev server datastore

痞子三分冷 提交于 2020-01-13 11:32:36
问题 In my application I have a set of of DAOs which I inject into my application layer. For an acceptance test I'm writing, I want to preload the dev_server datastore with data, so I use the same Spring config in my JUnit test (using the @ContextConfiguration annotation) to inject an instance of the relevant DAO into my test. When I actually go to store some data eg: dao.add(entity) I get the dreaded "No API environment is registered for this thread." Caused by: java.lang.NullPointerException: No

access css class properties in selenium

﹥>﹥吖頭↗ 提交于 2020-01-13 04:36:06
问题 I have a HTML <div> element and wish to check if it is left aligned using Selenium. However the float:left CSS property is defined in a CSS class. Is there any way in which I can access the CSS class attributes through Selenium? Alternately is there any other way to get this value? <div class="myclass"> ... </div> In sample.css .myclass{ float:left; } I was trying to use getEval() - this.page().findElement("foo") to find out a way to get CSS class attributes. 回答1: With webdriver you can use

Testcase level variables in [Documentation] for robot framework

不想你离开。 提交于 2020-01-12 08:48:05
问题 I cannot get test level variables to appear in documentation. Let's say I have this testsuite: | *Variables* | | ${SystemUnderTest} = | Staging | *testcase* | | Device Test | | | Set Test Variable | ${device} | iPhone | | [Documentation] | Device is: ${device} | | | ... | System is: ${SystemUnderTest} | | | No Operation That produces this log: TEST CASE: Device TestExpand All Full Name: T.Device Test Documentation: Device is: ${device} System is: Staging Notice that the Suite level variable