Create Article - Links Multiple Values
//table/*//input[starts-with(@id,"edit-field-links")]'
$x('//table/*//input[starts-with(@id,"edit-field-links")]')
(4) [input#edit-field-links-0-uri--kqe8gMbTwQ0.form-autocomplete.form-text.ui-autocomplete-input, input#edit-field-links-0-title--LRVpDrS0r8M.form-text, input#edit-field-links-1-uri--Np7fGnJEb9A.form-autocomplete.form-text.ui-autocomplete-input, input#edit-field-links-1-title--axXfvkpAN3o.form-text]
$x('//table/*//input[starts-with(@id,"edit-field-links-0-title")]')
[input#edit-field-links-0-title--LRVpDrS0r8M.form-text]
$x('//table/*//input[starts-with(@id,"edit-field-links-0-uri")]')
[input#edit-field-links-0-uri--kqe8gMbTwQ0.form-autocomplete.form-text.ui-autocomplete-input]
Parse this down to selectors, but has good strategies for iframe and 'mouse-hover' actions
/*package stepDefinitions;
import java.util.Map;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import cucumber.api.DataTable;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class DealStepWithMapDefinition {
WebDriver driver;
WebElement el;
@Given("^user is already on Login Page$")
public void user_is_already_on_Login_Page() {
System.setProperty("webdriver.chrome.driver", "W:\\w\\java\\lib\\SeleniumWebDrivers\\chromedriver\\2.39\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.freecrm.com");
}
@When("^title of login page is Free CRM$")
public void title_of_login_page_is_Free_CRM() {
String title = driver.getTitle();
System.out.println(title);
Assert.assertEquals("Free CRM software in the cloud powers sales and customer service", title);
}
// @Then("^user enters \"([^\"]*)\" and \"([^\"]*)\"$")
// public void user_enters_username_and_password(String username, String password) {
// driver.findElement(By.xpath("//input[@name='username']")).sendKeys(username);
// driver.findElement(By.name("password")).sendKeys(password);
// }
@Then("^user enters username and password$")
public void user_enters_username_and_password(DataTable credentials){
// Map<String, String> data = (Map<String, String>) credentials.asMaps(String.class, String.class); //map returns map of <String, String>, then pipe to Map<S,S>
for(Map<String, String> data: credentials.asMaps(String.class, String.class)) {
driver.findElement(By.xpath("//input[@name='username']")).sendKeys(data.get("username"));
driver.findElement(By.name("password")).sendKeys(data.get("password"));
}
}
@Then("^user clicks on login button$")
public void user_clicks_on_login_button() {
//Xpath.click technique
el = driver.findElement(By.xpath("//input[@type='submit']"));
el.click();
// might have to use JavaScript technique
// el = driver.findElement(By.xpath("//input[@type='submit']"));
// JavascriptExecutor js = (JavascriptExecutor)driver;
// js.executeScript("arguments[0].click", el);
}
@And("^user is on home page$")
public void user_is_on_home_page() {
String title = driver.getTitle();
System.out.println("HomePage title is :" + title);
Assert.assertEquals("CRMPRO", title);
}
@Then("^user moves to new deal page$")
public void user_moves_to_new_deal_page(){
//move to frame ( view frame source )
// wasn't working
// driver.switchTo().frame("manpanel");
el = driver.findElement(By.xpath("//frame[@name='mainpanel']"));
driver.switchTo().frame(el);
//mouse over the menu item
Actions action = new Actions(driver); //new action
// findElement.... build action to MOVE to element....
action.moveToElement(driver.findElement(By.xpath("//a[contains(.,'Deals')]"))).build().perform();
// wasn't working
// driver.findElement(By.xpath("//a[contains(.,'New Contact']")).click();
// THEN click
action.moveToElement(driver.findElement(By.xpath("//a[contains(.,'New Deal')]"))).build().perform();
el = driver.findElement(By.xpath("//a[contains(.,'New Deal')]"));
el.click();
}
@Then("^user enters contact details$")
public void user_enters_contact_details(DataTable dealData){
for ( Map<String,String> data : dealData.asMaps(String.class, String.class)){
driver.findElement(By.id("title")).sendKeys(data.get("title"));
driver.findElement(By.id("amount")).sendKeys(data.get("amount"));
driver.findElement(By.id("probability")).sendKeys(data.get("probability"));
driver.findElement(By.id("commission")).sendKeys(data.get("commission"));
driver.findElement(By.xpath("//input[@value='Save' and @type='submit']")).click();
// move to new deal page
Actions action = new Actions(driver); //new action
action.moveToElement(driver.findElement(By.xpath("//a[contains(.,'Deals')]"))).build().perform();
action.moveToElement(driver.findElement(By.xpath("//a[contains(.,'New Deal')]"))).build().perform();
el = driver.findElement(By.xpath("//a[contains(.,'New Deal')]"));
el.click();
}
}
@Then("^close the browser$")
public void close_the_browser(){
driver.quit();
}
}
*/
- Log in to post comments
