maven - Error during converting Selenium Java project to Page Object Design Pattern -
I also created 4 squares after deciding to convert my project to this design pattern. I took my code inside the classes of related classes, I am facing failures while compiling and I do not know why
main category
GidiyorTest.java
public class GidiyorTest {secure WebDriver driver; Protected string base url; Accept private boolean; Alternative option = true; Private string buffer verification errors = new stringbuffers (); Static Gideor Test Gestiggior = New Gidiar Test (); Fixed String Generated Mail = gittiGidiyor.generateString (); Constant String GeneratedUser = gittiGidiyor.generateString (); Stable register page register page = new register page (); Fixed login page login page = new login page (); Static Search Page Search Page = New Search Page (); Fixed discount page discount page = new discount page (); Public String Generated String () {char [] Characters = "ABCDEFGHKLMNOPQRTUVXZ" .tocarry (); Stringbilder sb = new stringbiller (); Random random = new random (); For (int i = 0; i register page. Java (one of the four new sections for just one)
Public category register page GidiyorTest expands {public zero registered (throws) Interrupted expression {driver.get (baseUrl + "/ kayit -ol "); Driver.findElement (By.name ("name")) Clear () .; Driver.findElement (By.name ("name")) SendKeys ("idol") .; Driver.findElement (By.name ("alias")) clear () .; Driver.findElement (By.name ("nickname")) SendKeys ("Yilmaz") .; Thread.Sleep (300); Driver.findElement (By.id ("suggestion_email_input_verifier")) Clear () .; Driver.findElement (By.id ("suggestion_email_input_verifier")) sendKeys (Generated Mail + "@ gmail.com"); Driver.findElement (By.id ("nickname")) Clear () .; Driver.findElement (By.id ("nickname")) SendKeys (generatedUsername). Thread.Sleep (300); . Driver.findElement (By.name ("password")) Clear (); Driver.findElement (By.name ("password")) SendKeys ("123456abc") .; . Driver.findElement (By.name ("passwd2")) Clear (); Driver.findElement (By.name ("passwd2")) SendKeys ("123456abc") .; Thread.Sleep (300); Driver.findElement (By.id ("cepgsm")) Clear () .; Driver.findElement (By.id ("cepgsm")) SendKeys ("531") .; Driver.findElement (By.id ("CEP")) Clear () .; Driver.findElement (By.id ("CEP")). SendCakes ("600 2979"); Thread.Sleep (1000); . Click on Driver.findElement (By.id ("SubmitForm")) (); }} and the registration register begins on the page. Registration (); Line. Each other has java.lang.NullPointerException.
Hope you can help.
The way you are creating your PageAbus is not right. You should not expand the test, one of the main points is that the Page object should not know anything about the test, not just the bus. On the other hand, your test should have logic and other testing related logic.
The second wrong thing is that you should use the PageFactory to instantiate your page object so that you can take advantage of the lazy binding mechanism. . Then change to do something
public class register page {Private WebDriver driver; Public Register Page (WebDriver Driver) {this.driver = driver; } // your rest class} and PageFactory
PageFactory.initElements (driver, RegisterPage.class); To reduce the maintenance and to benefit from lazy elements, you can think of adding your elements as fields, and mark them through annotations. So they can PageFactory as well as
public class register page {Private WebDriver driver; Public Register Page (WebDriver Driver) {this.driver = driver; } @FindBy (name = "name") Name of Private Web Element; ...}}
Comments
Post a Comment