Change-Id: I2c3be045340edda6cf9d5b6422dec8b031bcf6dctags/7.6.0.alpha3
@@ -0,0 +1,60 @@ | |||
/* | |||
* Copyright 2000-2014 Vaadin Ltd. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||
* use this file except in compliance with the License. You may obtain a copy of | |||
* the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.components.embedded; | |||
import org.junit.Assert; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.elements.EmbeddedElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class EmbeddedAltTextTest extends MultiBrowserTest { | |||
@Before | |||
@Override | |||
public void setup() throws Exception { | |||
super.setup(); | |||
openTestURL(); | |||
waitForElementPresent(By.className("v-embedded")); | |||
} | |||
@Test | |||
public void testEmbeddedAltText() { | |||
EmbeddedElement embedded = $(EmbeddedElement.class).first(); | |||
Assert.assertEquals("Alt text of the image", getAltText(embedded)); | |||
assertHtmlSource("Alt text of the object"); | |||
$(ButtonElement.class).first().click(); | |||
Assert.assertEquals("New alt text of the image!", getAltText(embedded)); | |||
assertHtmlSource("New alt text of the object!"); | |||
} | |||
private void assertHtmlSource(String html) { | |||
String pageSource = driver.getPageSource(); | |||
Assert.assertTrue("Page source does not contain '" + html + "'", | |||
pageSource.contains(html)); | |||
} | |||
private String getAltText(EmbeddedElement embedded) { | |||
return embedded.findElement(By.vaadin("/domChild[0]")).getAttribute( | |||
"alt"); | |||
} | |||
} |
@@ -1,47 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |||
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> | |||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |||
<link rel="selenium.base" href="http://localhost:8068" /> | |||
<title>EmbeddedAltText</title> | |||
</head> | |||
<body> | |||
<table cellpadding="1" cellspacing="1" border="1"> | |||
<thead> | |||
<tr><td rowspan="1" colspan="3">EmbeddedAltText</td></tr> | |||
</thead><tbody> | |||
<tr> | |||
<td>open</td> | |||
<td>/run/com.vaadin.tests.components.embedded.EmbeddedAltText?restartApplication</td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td>assertAttribute</td> | |||
<td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedAltText::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VEmbedded[0]/domChild[0]@alt</td> | |||
<td>Alt text of the image</td> | |||
</tr> | |||
<tr> | |||
<td>assertHtmlSource</td> | |||
<td>*Alt text of the object*</td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td>click</td> | |||
<td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedAltText::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td>assertAttribute</td> | |||
<td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedAltText::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VEmbedded[0]/domChild[0]@alt</td> | |||
<td>New alt text of the image!</td> | |||
</tr> | |||
<tr> | |||
<td>assertHtmlSource</td> | |||
<td>*New alt text of the object!*</td> | |||
<td></td> | |||
</tr> | |||
</tbody></table> | |||
</body> | |||
</html> |