Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
1. Add logging to Scene
2. Add logging to Pallete
  • Loading branch information
artbez committed Nov 4, 2016
1 parent 218c5ff commit 3a55d67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.codeborne.selenide.SelenideElement;
import org.openqa.selenium.By;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import static com.codeborne.selenide.Selenide.$;
Expand All @@ -15,13 +17,17 @@ public class Pallete {

private final String selector = "#palette-tab-content";

private static final Logger logger = LoggerFactory.getLogger(Pallete.class);

/**
* Chose element from Pallete.
*
* @param elementName name of block
* @return block
*/
public SelenideElement getElement(String elementName) {
return $(By.cssSelector(selector + " div[data-type=\"" + elementName + "\"]"));
SelenideElement element = $(By.cssSelector(selector + " div[data-type=\"" + elementName + "\"]"));
logger.info("Get element {} from Palette", element);
return element;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Actions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.HashSet;
Expand All @@ -28,6 +30,8 @@ public class Scene {

private WebDriver driver;

private static final Logger logger = LoggerFactory.getLogger(Pallete.class);

/** For actions such as mouse move we need driver of current page. */
public void updateWebdriver(WebDriver webDriver) {
driver = webDriver;
Expand All @@ -45,6 +49,7 @@ public SelenideElement dragAndDrop(SelenideElement element) {
SelenideElement newEl = all.stream().filter(x ->
!elements.stream().anyMatch(y -> x.attr("id").equals(y.attr("id")))).findFirst().orElse(element);
elements.add(newEl);
logger.info("Add element {} to scene", newEl);
return newEl;
}

Expand All @@ -57,6 +62,7 @@ public SelenideElement dragAndDrop(SelenideElement element) {
*/
public void moveElement(SelenideElement element, int offset_x, int offset_y) {
assert exist(element);
logger.info("Move element {} with offsets {} and {}", element, offset_x, offset_y);
new Actions(driver).dragAndDropBy(element, offset_x, offset_y).build().perform();
}

Expand All @@ -73,6 +79,7 @@ public Pair getPosition(SelenideElement selenideElement) {

/** Remove element from the scene. */
public void remove(SelenideElement selenideElement) {
logger.info("Remove element {} form scene", selenideElement);
elements.remove(selenideElement);
new Actions(driver).contextClick(selenideElement).build().perform();
$(By.id("scene-context-menu")).click();
Expand All @@ -85,6 +92,7 @@ public void clean() {
$(By.id("scene-context-menu")).click();
});
elements.clear();
logger.info("Clean scene");
}

}

0 comments on commit 3a55d67

Please sign in to comment.