@FindBy(id="userNameId")
private SelenideElement userID;
//private WebElement userID;
Running into following error:
"Can not set com.codeborne.selenide.SelenideElement field pages.Login.userID to com.sun.proxy.$Proxy8"
My structure is as under:
public abstract class Page1
public abstract class Page2 extends Page1
public class Login extends Page2
Thx.
-Vin
Hi Vin!
What Selenide version are you using?
I guess it should be fixed in latest version 3.6
--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Replying to your previous post:
Point 2: Page object initialization:
Login page extends Page2
Initialization takes place within the constructor of Page2 as under:
public abstract class Page2 extends Page1
{
protected Page2()
{
super();
PageFactory.initElements(driver, this);
}
Point 1: Stack trace:
java.lang.AssertionError: Can not set com.codeborne.selenide.SelenideElement field pages.Login.userID to com.sun.proxy.$Proxy8
at org.testng.Assert.fail(Assert.java:94)
at supportlibraries.DriverScript.wrapUp(DriverScript.java:617)
at supportlibraries.DriverScript.driveTestExecution(DriverScript.java:120)
at testscripts.RegressionSuite.LoginTests.tc3(LoginTests.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Ok, clear. You are using selenium PageFactory that knows nothing about SelenideElements. Don't use PageFactory, use selenide method:
MyPage myPage = page(MyPage.class);
What library will I need to import to get this working?
Just putting the above line in the constructor should take care of the initialization of page objects?
-Vin
This is selenide method. No new libraries needed. Don't put this line into constructor, but use it INSTEAD OF constructor. Your page object does not need constructor at all.
java.lang.AssertionError: Failed to create new instance of class pages.Login <b>Caused by: </b>java.lang.NoSuchMethodException: pages.Login.<init>()
I need to use the extension to provide features built into the framework.
So, how do I use Selenide while still extending Mypage class?
-Vin
You can extend Page2, but add default public constructor to class Login. Look, error message clearly says that default constructor is missing.
P.S. Are you sure you have upgraded to Selenide 3.6? It should not require constructor.
Do I need to switch to 3.6?
-Vin
-Vin
-Vin
That's the point!
Login class doesn't have public parameterless constructor. That's why Selenide cannot create instance of this class.
-Vin
--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+unsubscribe@googlegroups.com.
@FindBy(id="userNameId")
private SelenideElement userID;
public void setUserID(String id) {
userID.setValue(id);
}
@FindBy(name = "displayName")
private SelenideElement productName;
public void setProductName(String name) {
productName.sendKeys(name);}
private String productName = "displayName";
$(By.name(productName)).sendKeys(name);
Andrei Solntsev
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.