selenium - Junit in Eclipse can not deal with a LinkText apostrophe -
a testcase runs in selenium ide when exported webdriver , executed in eclipse junit script can not find linktext element apostrophe in name.
i escaped apostrophe still junit can not find it.
the line in question highlighted in code
i exported selenuim testcase did not contain apostrophes , able run webdriver junit test in eclipse without issues.
i continue using testcases without apostrophes great if figure out how deal special characters.
sincerely,
rick doucette
import java.util.regex.pattern; import java.util.concurrent.timeunit; import org.junit.*; import static org.junit.assert.*; import static org.hamcrest.corematchers.*; import org.openqa.selenium.*; import org.openqa.selenium.firefox.firefoxdriver; import org.openqa.selenium.support.ui.select; public class firstselidedemo { private webdriver driver; private string baseurl; private boolean acceptnextalert = true; private stringbuffer verificationerrors = new stringbuffer(); @before public void setup() throws exception { driver = new firefoxdriver(); baseurl = "http://www.soastastore.com/"; driver.manage().timeouts().implicitlywait(30, timeunit.seconds); } @test public void testfirstselidedemo() throws exception { driver.get(baseurl + "/"); driver.findelement(by.linktext("store")).click(); driver.findelement(by.linktext("tron: legacy")).click(); driver.findelement(by.id("product_155_submit_button")).click(); new select(driver.findelement(by.name("product_rating"))).selectbyvisibletext("2"); driver.findelement(by.id("s")).clear(); driver.findelement(by.id("s")).sendkeys("firth"); driver.findelement(by.id("searchsubmit")).click(); *****driver.findelement(by.linktext("the king\'s speech")).click();***** driver.findelement(by.name("product_rating")).click(); new select(driver.findelement(by.name("product_rating"))).selectbyvisibletext("4"); driver.findelement(by.cssselector("form.wpsc_product_rating > input[type=\"submit \"]")).click(); driver.findelement(by.id("product_160_submit_button")).click(); new select(driver.findelement(by.name("product_rating"))).selectbyvisibletext("4"); driver.findelement(by.cssselector("form.wpsc_product_rating > input[type=\"submit\"]")).click(); driver.findelement(by.id("product_160_submit_button")).click(); driver.findelement(by.linktext("checkout")).click(); driver.findelement(by.cssselector("form.adjustform.remove > input[name=\"submit\"]")).click(); driver.findelement(by.cssselector("span > input[name=\"submit\"]")).click(); // warning: asserttextpresent may require manual changes asserttrue(driver.findelement(by.cssselector("body")).gettext().matches("^[\\s\\s]*error: please enter username\\.[\\s\\s]*$")); } @after public void teardown() throws exception { driver.quit(); string verificationerrorstring = verificationerrors.tostring(); if (!"".equals(verificationerrorstring)) { fail(verificationerrorstring); } }
you don't need escape apostrophe in java source code, can lose \
. generated html valid (it should have '
in source, if it's in attribute)? perhaps it's not '
(code u+0027) else u+2019 (http://www.fileformat.info/info/unicode/char/2019/index.htm)?
Comments
Post a Comment