0

Could we replace selenium with geb in a python test automation script . Geb being implemented in groovy java and python being an independent language.

example code:

groovy geb code 
import geb.Page

import org.openqa.selenium.By

class GooglePage extends Page {
        static at = { title == "Google" }
        static url = "http://www.google.com"
        static content = {
        searchField(wait:true) { $("input", name:"q")}
        submit(wait:true) { $("button", name:"btnG")}
    }
}

python:

Enter text into the searchField

searchField = "Google"

is it possible to accomplish this if yes please comment.

Community
  • 1
  • 1

1 Answers1

0

Anything is possible my friend. the question really is how hard will it be to implement.

The first thing is: is python utilizing webdriver? python will need to be driving the browser for this to work. Next, a page object is just like any other Java class. if you are usually able to interface with java classes from python, then you should be able to do this.

Please see Calling Java from Python on how to call java from python.

Now I would very much recommend you don't do this through python because you can simply call searchField.value("google") to do what you want from the geb scope, but to each their own I suppose.

Please see Peter Niederwieser's answer to this question: running a geb test from a java class

Community
  • 1
  • 1
switch201
  • 587
  • 1
  • 4
  • 16