Untitled

                Never    
C#
       
using OpenQA.Selenium;
using System;

namespace FillOutForm_tests
{
    class FillOutForm
    {
        IWebDriver driver;

        //Constuctor
        public FillOutForm(IWebDriver driver)
        {
            this.driver = driver;
        }
        
            
         
        //Locators
        public String NAME_TEXT_FIELD = "et_pb_contact_name_1";
        public String MESSAGE_TEXT_FIELD = "et_pb_contact_message_1";
        public String SUM_EXPRESSION_FIELD = "et_pb_contact_captcha_question";
        public String SUBMIT_BUTTON = "//div [@class = 'et_pb_column et_pb_column_1_2 et_pb_column_1    et_pb_css_mix_blend_mode_passthrough']//button";
        public String RESULT_FIELD = "et_pb_contact_captcha_1";
        public String SUCCESS_ERROR_FIELD = "//div[@id = 'et_pb_contact_form_1']//div[@class = 'et-pb-contact-message']";

        //Get the web elements
        public IWebElement GetNameField()
        {
            return this.driver.FindElement(By.Id(NAME_TEXT_FIELD));

        }

        public IWebElement GetMessageField()
        {
            return this.driver.FindElement(By.Id(MESSAGE_TEXT_FIELD));
        }

        public IWebElement GetTheResultField()
        {
            return this.driver.FindElement(By.Name(RESULT_FIELD));
        }

        public IWebElement GetSubmitButton()
        {
            return driver.FindElement(By.XPath(SUBMIT_BUTTON));
        }

        public IWebElement GetTheSumExpresionElement()
        {
            return driver.FindElement(By.ClassName(SUM_EXPRESSION_FIELD));
        }

        public IWebElement GetSuccessErrorDiv()
        {
            return driver.FindElement(By.XPath(SUCCESS_ERROR_FIELD));
        }


        //Actions on the web elements
        public void FillNameField(String name)
        {
            GetNameField().SendKeys(name);
        }

        public void FillMessageField(String message)
        {
            GetMessageField().SendKeys(message);
        }

        public void FillResultField(int result)
        {
            GetTheResultField().SendKeys(result.ToString());
        }

        public void ClickOnSubmitButton()
        {
            GetSubmitButton().Click();
        }

        public String GetSucessErrorMsgText()
        {
            return GetSuccessErrorDiv().Text;
        }

        public String GetSumExpressionText()
        {
            return GetTheSumExpresionElement().Text;
        }

    }

}