Selenium | Creating Base Class For Page Objects | Tutorial #10

preview_player
Показать описание
In this tutorial, I talk about setting up a Base Page for Page Objects. This is extremely useful for putting all your generic/general methods and housing all Page variables such as page url or title.
Рекомендации по теме
Комментарии
Автор

too good..you are amazing ! The best tutorials ever seen on youtube.Honestly,

kishorenegi
Автор

I liked your videos they are very clear and everything properly explained.
I used this framework in one of technical test for a job and they rejected me saying the code/structure is confusing, you kept assertions in BaseClass and I was not able to convince him.

nidhijoshi
Автор

Gr8
I have question to U. I have got some exercise, and I'm not sure how structure and test/tests classes should look like. Exercise sounds like:
-create an optimal solution
-should be possible to run solution in CI
-it shoudl bootstramp itself(install depend)

1.Login to the webapp
2.Create new lead
3.check that leasd stat is "new"
4.goto settings, change status name of "new" to other.

So I Have pages, I should use:
MainPage
LoginPage
LeadsPage
AddLead
SettingsPage
ChangeStatNamePage

But Im not sure how should looks test class, everything in one tess class or other solution?

rogowskikam
Автор

I'm getting a "IWebdriver does not have a definition for get" error in the driver.get(getPageURL()) line for the load page function. What am I missing?

using System;
using
using OpenQA.Selenium;




namespace QADemo.Page_Objects
{
public class BasePage
{
public IWebDriver driver;
public String page_URL;
public String user;
public String pass;

public BasePage (IWebDriver driver)
{
this.driver = driver;
}

public void loadPage()
{
driver.get(getBASEURL()); //Here I'm getting the error.
}

PatoMiner
Автор

can you help me with two doubts.
1. why did this.driver = driver; did not work, super(driver) -- what is this.
2. What if i need to create page fatory in a class which has all opjects of all pages. and then use those WebElement objects in other classes.

roystangomes
Автор

Hi QA-Automan!

Got another question for you (hope I'm not overloading you!):

Would you recommend Assert validating the BasePage selectValueInDropdown method, and if so, how would you recommend you doing it?

I came up with something along the lines of:

Assert.assertEquals((dropdown.getFirstSelectedOption()).getText(), value);

But I wasn't sure if you didn't validate that intentionally.



As always, many thanks! :D

Dtromblee
Автор

I made basepage class like in tutorial and i try to use super(driver), but i have errors:
I dont know what is wrong...

rogowskikam
Автор

hello, good tutorials! Can you share your code with git or something else?

makskharchenko
Автор

Isn't putting asserts in a page file a no-no?

devonjones