java - how can i validate span tag text using single xpath? -


my html code below:

<div class="row"> <div class="col-lg-7"> <h1 class="h1_home"> <span>welcome the</span> <br/> <span>automation software testing</span> </h1> <p class="col-xs-9 col-lg-12"> </div> </div> 
  1. verify page header text use bellow code :

    string expected_txt = "welcome automation software testing"; webelement header_txt_elm=driver.findelement(by.xpath(".//h1[@class='h1_home']//span")); string actual_headertxt = header_txt_elm.gettext().tostring(); assert.assertequals( actual_headertxt.tolowercase(), expected_txt.tolowercase()); 
  2. getting error:

    java.lang.assertionerror: expected [welcome automation software testing] found [welcome the] 

string expected_txt = "welcome automation software testing"; webelement header_txt_elm = driver.findelement(by.xpath("//*[text()='welcome the']")); webelement header_txt_elm2 = driver.findelement(by.xpath("//*[text()='automation software testing']")); string actual_txt1=header_txt_elm.gettext(); string actual_txt2=header_txt_elm2.gettext(); string actual_txt=actual_txt1+actual_txt2; assert.assertequals(actual_headertxt, expected_txt); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -