Example #1
0
        public static API_WordPress_IE open(this API_WordPress_IE apiWordPressIE, string virtualPath)
        {
            var fullUri = apiWordPressIE.ServerUri.append(virtualPath);

            apiWordPressIE.ie.open(fullUri.str());
            return(apiWordPressIE);
        }
        //public AlertAndConfirmDialogHandler alertsHander;

    	public Unit_Tests_API_WordPress_IE() 
    	{    		
    		base.set_IE_Object("Unit_Tests_API_WordPress_IE");
    		//alertsHander = ie.getAlertsHandler();
    		var serverUrl = "https://o2platform.wordpress.com".uri();
			apiWordPressIE = new API_WordPress_IE(ie, serverUrl);		
			
			base.CLOSE_BROWSER_IN_SECONDS = 0;
			//base.minimized();
    	}
Example #3
0
        public static API_WordPress_IE login(this API_WordPress_IE apiWordPressIE)
        {
            if (apiWordPressIE.UserDetails.isNull())
            {
                apiWordPressIE.UserDetails = ascx_AskUserForLoginDetails.ask();
            }
            var credential = apiWordPressIE.UserDetails;

            if (credential.notNull())
            {
                apiWordPressIE.loginPage();
                ie.field("log", credential.UserName);
                ie.field("pwd", credential.Password);
                ie.button("Log In").click();
            }
            else
            {
                "[API_WordPress_IE] [login] no credentials provided".error();
            }
            return(apiWordPressIE);
        }
Example #4
0
        public static string uploadPicture_viaHttp(this API_WordPress_IE apiWordPressIE, string fileToUpload, string wpnonce, string postId, string loggedInCookie, string authCookie, string cookies)
        {
            var httpMultiPartForm = new HttpMultiPartForm();

            string postUrl  = apiWordPressIE.ServerUri.append("/wp-admin/async-upload.php").str();
            string fileName = fileToUpload.fileName();
            //string fileFormat = "jpeg";
            string userAgent = "O2Platform.com";

            FileStream fs = new FileStream(fileToUpload, FileMode.Open, FileAccess.Read);

            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, data.Length);
            fs.Close();

            var postParameters = new Dictionary <string, object>();

            postParameters.Add("Filename", fileName);
            postParameters.Add("_wpnonce", wpnonce);
            postParameters.Add("post_id", postId);
            postParameters.Add("type", "image");
            postParameters.Add("tab", "type");
            postParameters.Add("logged_in_cookie", loggedInCookie);
            postParameters.Add("short", "1");
            postParameters.Add("auth_cookie", authCookie);


            string fileContentType = "multipart/form-data";            //"application/octet-stream";

            postParameters.Add("async-upload", new HttpMultiPartForm.FileParameter(data, fileName, fileContentType));

            var          httpWebResponse = httpMultiPartForm.MultipartFormDataPost(postUrl, userAgent, postParameters, cookies);
            StreamReader reader          = new StreamReader(httpWebResponse.GetResponseStream());
            string       responseHtml    = reader.ReadToEnd();

            httpWebResponse.Close();
            return(responseHtml);
        }
Example #5
0
 public static API_WordPress_IE loginPage(this API_WordPress_IE apiWordPressIE)
 {
     return(apiWordPressIE.open("/wp-login.php"));
 }
Example #6
0
 public static API_WordPress_IE homePage(this API_WordPress_IE apiWordPressIE)
 {
     return(apiWordPressIE.open("/"));
 }
Example #7
0
 public static API_WordPress_IE wordPress_com(this API_WordPress_IE apiWordPressIE)
 {
     apiWordPressIE.ie.open("http://wordpress.com");
     return(apiWordPressIE);
 }