This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define Package Name | |
package wpAdmin; | |
// Import Selenium Libraries | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.JavascriptExecutor; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
// Define Class Name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Navigate to the title box and enter the title | |
driver.findElement(By.id("title-prompt-text")).sendKeys("<Post Title>"); | |
// Change the editor to the basic HTML editor | |
driver.findElement(By.id("content-html")).click(); | |
// Navigate to the content area and enter the post content | |
driver.findElement(By.className("wp-editor-area")).sendKeys("<Post Content>"); | |
// Navigate to the tags area and input the tags seperated by , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Click on the post link from the left navigation bar and navigate to All Post page | |
driver.findElement(By.xpath("//*[@id='menu-posts']/a/div[2]")).click(); | |
// Open the New Post page by clicking on the Add Post button | |
driver.findElement(By.xpath("//*[@id='wpbody-content']/div[3]/h1/a")).click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Registration URL | |
String regurl = "http://<YourWebsiteURL>/wp-login.php"; | |
// Opening New Firefox Window | |
WebDriver driver = new FirefoxDriver(); | |
// Open Registration URL | |
driver.get(regurl); | |
// Maximize the browser window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Finding Username element and entering values | |
driver.findElement(By.id("user_login")).sendKeys("<username>"); | |
// Finding Email element and entering values | |
driver.findElement(By.id("user_pass")).sendKeys("<password>"); | |
// Finding Submit button and Clicking it | |
driver.findElement(By.id("wp-submit")).click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define Package Name | |
package wpAdmin; | |
// Import Selenium Libraries | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.JavascriptExecutor; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
// Define Class Name |