geb

Geb tests pass with Chrome, fail with PhantomJS

假装没事ソ 提交于 2019-12-23 10:28:23
问题 I have noticed that some Geb functional tests pass with Chrome but fail with PhantomJS, holding all other variables constant. This happens mostly with pages that have some kind of asynchronous activity - one call to $(selector).click() triggers an event handler that updates the DOM, and the DOM updates need to complete before calling $(anotherSelector).click() . I can make the PhantomJS tests pass again by aggressively using waitFor but I don't understand why this would be required with the

Geb & Spock - If/Then/Else logic - How to check for a record and do one thing if it exists but continue on if it doesn't

蓝咒 提交于 2019-12-23 01:42:03
问题 I'm testing the creation and then removal of a record on my site using Geb/Spock. However I can't create the record if it already exists and so I check for the existence of the record and remove it if it exists in the beginning of the test. The problem occurs when the record does not exist, causing the test to fail. Is there a way to incorporate some if/then/else logic so the test will continue if it does not find the record in the beginning and remove it if it does find it? Edit for example

How to handle server authentication using Geb/WebDriver

和自甴很熟 提交于 2019-12-22 14:43:10
问题 I have a web page. When I open that web page first it ask for server authentication. After providing the server authentication it allows me to navigate the web site. I have to automate that web page but because of the server authentication I am unable to move forward. How I can handle this server authentication in Geb or Web Driver 回答1: Try using this : http://username:password@site.com/page Instead of : http://site.com/page 回答2: This is called basic auth. So you can pass username and

Geb: Waiting/sleeping between tests

半世苍凉 提交于 2019-12-22 10:18:24
问题 Is there a way to wait a set amount of time between tests? I need a solution to compensate for server lag. When creating a record, it takes a little bit of time before the record is searchable in my environment. In the following code example, how would I wait 30 seconds between the first test and the second test and have no wait time between second test and third test? class MySpec extends GebReportingSpec { // First Test def "should create a record named myRecord"() { given: to

Executing Specific Geb Tests according to environment

自闭症网瘾萝莉.ら 提交于 2019-12-20 10:55:52
问题 I have a set of Spec tests I am executing within a Grails Project. I need to execute a certain set of Specs when I am on local, and another set of Spec when I run the pre-prod environment. My current config is executing all my specs at the same time for both environements, which is something I want to avoid. I have multiple environments, that I have configured in my GebConfig: environments { local { baseUrl = "http://localhost:8090/myApp/login/auth" } pre-prod { baseUrl = "https://preprod

invoking GORM methods from Geb tests

自作多情 提交于 2019-12-20 04:39:08
问题 In my Grails app, I have a suite of Geb tests wherein I invoke various GORM methods to save/retrieve data. This was working fine, until very recently. But now, whenever I try to invoke a GORM method from a Geb test, I get the following error: Method on class [com.example.MyDomainClass] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly. I'm aware of the fact that under certain circumstances you need to use the

Mantain session between tests using Geb

ぐ巨炮叔叔 提交于 2019-12-19 11:36:26
问题 I'm testing my application using Geb, and I want to mantain session between tests so I can avoid to log in in every tests (this is annoying when watching the tests in the browser). Is there a way to mantain the session? 回答1: By default Geb test integrations clear all the cookies after every test which means that you loose your web sessions. You can easily change that behaviour by using the following configuration option in your GebConfig.groovy: autoClearCookies = false You can read more

Mantain session between tests using Geb

自闭症网瘾萝莉.ら 提交于 2019-12-19 11:36:08
问题 I'm testing my application using Geb, and I want to mantain session between tests so I can avoid to log in in every tests (this is annoying when watching the tests in the browser). Is there a way to mantain the session? 回答1: By default Geb test integrations clear all the cookies after every test which means that you loose your web sessions. You can easily change that behaviour by using the following configuration option in your GebConfig.groovy: autoClearCookies = false You can read more

Geb - IncompatibleClassChangeError

依然范特西╮ 提交于 2019-12-18 05:13:21
问题 I'm just starting out with Geb and am encountering this error when inputting sample code from the Book of Geb: import geb.Browser Browser.drive { go "http://google.com/ncr" // make sure we actually got to the page assert title == "Google" // enter wikipedia into the search field $("input", name: "q").value("wikipedia") // wait for the change to results page to happen // (google updates the page dynamically without a new request) waitFor { title.endsWith("Google Search") } // is the first link

Determine order of execution of Spock tests

旧街凉风 提交于 2019-12-18 03:56:19
问题 Is there a way to set the order in which tests are executed within an Spock Specification? For example: class MySpec extends IntegrationSpec { def 'test A'... def 'test B'... } I want 'test A' to be execute always before 'test B' This is because I'm doing some functional tests with Geb and Spock and data is not rolled back between tests. 回答1: You can use @Stepwise annotation on a spec and spock will run each of the test definitions of the Spec in the order they are specified. Look at this