vendredi 1 septembre 2017

How can i compare the screenshot of webelement with predifined one using Sikuli + Java + WebDriver?

i want something like that:

> @FindBy(xpath = "//*[@class = 'ui primary fluid button
> js-start-free-trial']")
> private WebElementFacade tryUsNowButton;
> 
> Screen s = new Screen();
> Pattern image = new Pattern("images/try-us-button.png");

make a screenshot of the tryUsNowButton and compare to image.

How to configure the beforeTestClass method of the AbstractTestExecutionListener class - Spring

In my project I need to prepare an environment for the execution of my integration tests, for this I use the @TestExecutionListeners annotation of spring, and I point a class, until this part is all right.

My problem is that when I'm going to give an insert in my database, in the beforeTestClass method of the AbstractTestExecutionListener insert statements do not work, in the TestExecutionListeners class I try to save a list of objects, but in my tests they are not there.

My test class

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/applicationContextTest.xml"})
@TransactionConfiguration(defaultRollback=true,             
transactionManager="defaultTransactionManager")
@TestExecutionListeners(listeners= {
        DependencyInjectionTestExecutionListener.class,
        TransactionalTestExecutionListener.class, 
        CriaPessoaEnvironment.class,
        }) 
public class EnvironmentTest {

    @Autowired
    private PessoaFacade PessoaFacade;

    @Test
    @Transactional
    public void verificaSeTem5cidadaosCadastrados() {
        List<Pessoa> listPessoa = pessoaFacade.listPessoa();

        System.out.println("Quantidade da lista: " + listPessoa.size());
        Assert.assertEquals(1, listPessoa.size());
    }
}

My enviromnent class

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/applicationContextTest.xml"})
@TestExecutionListeners({CriaPessoaEnvironment.class})
public class CriaPessoaEnvironment extends AbstractTestExecutionListener{

    @Autowired
    private PessoaFacade pessoaFacade;

    @Override
    public void beforeTestClass(TestContext testContext) throws Exception {
        TransactionalTestExecutionListener     
transactionalTestExecutionListener = new TransactionalTestExecutionListener();
    transactionalTestExecutionListener.beforeTestClass(testContext);
    testContext.getApplicationContext().getAutowireCapableBeanFactory().autowireBean(this);
    pessoaFacade.gravarPessoa(criaPessoa());
    }
}

"developer/test" mode for SQL Databases

I am new to a relatively large project using a Microsoft SQL server database with C# and the Entity Framework.

The current development process is like this:

  • Code some feature/intend to fix a bug
  • Start the application
  • Make some changes via GUI to the database testing the coded functionality/testing if the bug was fixed
  • In case of failure -> run SQL scripts to delete the complete database changes and repeat the whole procedure

I am wondering if there is any "test/developer"-mode for SQL databases that could automatically revert the applied changes. Basically, while the program is running, everything should be inserted/updated/deleted to the actual database, but afterwards all changes should automatically be reverted. Is my thought completely unreasonable? Is our procedure with the SQL scripts more or less state of the art for database development?

Thanks in advance!

How to test transcluded content in Angular?

While testing an Angular component that has transclusion slots with <ng-content>, we have no explicit means to check if the transcluded content is placed as intended inside the component. For example:

// base-button.component.ts
@Component({
  selector: 'base-button',
  template: `<button [type]="type">
    <ng-content></ng-content>
  </button>`,
})
export class BaseButtonComponent {
  @Input() type = 'button';
}

Basically, when creating a component instance in the spec file, we do this:

// base-button.component.spec.ts
it('should reflect the `type` property into the "type" attribute of the button', () => {
  const fixture = TestBed.createComponent(BaseButtonComponent);
  fixture.detectChanges();

  const { componentInstance, nativeElement } = fixture;
  componentInstance.type = 'reset';

  const button = nativeElement.querySelector('button');
  expect(button.type === 'reset');
});

We can do this for every property and method of the component, but what about the transcluded content? A workaround would be creating a host component for test purposes:

// base-button.component.spec.ts
...
@Component({
  template: `<base-button>Foo bar</base-button>`
})
export class BaseButtonHostComponent {}
...

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ BaseButtonComponent, BaseButtonHostComponent ]
    })
    .compileComponents();
  }));

  it('should transclude the content correctly', () => {
    const hostFixture = TestBed.createComponent(BaseButtonHostComponent);
    hostFixture.detectChanges();
    const button = hostFixture.nativeElement.querySelector('button');
    expect(button.textContent === 'Foo bar');
  });
...

But, as you could imagine, this is rather inconvenient, also because this has to be done for every component with transcluded content, and possibly for every <ng-content> element in its template. Is there another way to do this?

Again: Multiple word search and replace in notepad++

I saw this question: Multiple word search and replace in notepad++ I tried to write the Substitutions.txt like this: good bad very good , very bad a sentence with some words , a sentence with other words .... but it does not work. How should I write the Substitutions.txt to let it work. Thanks Hans

How to test workability of large registration form?

I have the registration form on my site: enter image description here

Now I'm testing(workability) the form and every time I make mistake in my code(wrong parameter name, dao problems) I have to retype all fields to test it one more time. Can I somehow automatize filling in? Are there something like plugins where I type field-value pairs and they will be filled for me?

What are best practices regarding my case?

How to perform end to end test for react native apps that needs to perform actions on Gallery, Contacts, Other Apps (FB/Google auth) etc

In our application, we are currently using Detox to perform the end to end tests. We can perform actions like clicks, fill forms etc. using Detox. But since our app requires a Facebook and Google login, access gallery and contacts, we need to test those features too.

Is there any E2E framework that allows to perform actions on other apps / external services? Also if we need to mock these environments, is there any recommended approach?

Would really appreciate advices and suggestions on this topic.