如何使用WebdriverJS在WebElement中查找WebElement?

时间:2015-08-23 14:25:42

标签: javascript node.js selenium-webdriver webdriverjs

如果这是HTML

<div>
 <div>
  <p class="my-element"></p>
 </div>
<div>
<div>
 <div>
   <p class="the-text"> I want to get this text</p>
 </div>
</div>
<div>
 <div>
  <p class="another-element"></p>
 </div>
<div>
<div>
 <div>
   <p class="the-text"> I DONT want to get this text</p>
 </div>
</div>

我的el是

var el = el.findElement(By.css(".my-element"));

我怎样才能获得p.the-文本文本?

我需要一个等同于

的jquery
el.parent().parent().find(".the-text")

1 个答案:

答案 0 :(得分:0)

您可以使用单个css选择器找到该元素,并使用CREATE PROCEDURE Sp_CopyAnnotation @AnnotationID int, @AssetVersionID int, @NewAssetVersionID int AS DECLARE @NewAnnotationID int DECLARE @Shape varchar(50) BEGIN insert into AnnotationMain(Text,x, y,Shape,Color,z1,JobID,AssetID,UserID,UserName,Department,AssetVersionID,HideAnnotation) select Text ,x ,y ,Shape ,Color ,z1 ,JobID ,AssetID ,AssetVersionID ,UserID,UserName ,Department ,@NewAssetVersionID ,1 from AnnotationMain where AnnotationID=@AnnotationID; --set @NewAnnotationID=@@IDENTITY select @NewAnnotationID=AnnotationID,@Shape=Shape from Proofing.AnnotationMain where AnnotationID=@@IDENTITY update AnnotationMain set Annoation_num=(select (max(Annoation_num)+1) from AnnotationMain where AssetVersionID=@AssetVersionID) where AnnotationID=@NewAnnotationID IF(@shape='ellipse') BEGIN Insert into CircleTable(AnnotationID,x1,x2,y1,y2) select @NewAnnotationID ,x1 ,x2 ,y1 ,y2 from CircleTable where AnnotationID=@AnnotationID select result=1; END ELSE IF(@shape='rectangle') BEGIN Insert into RectangleTable(AnnoationID,x,y,w,h) select @NewAnnotationID ,x ,y ,w ,h from RectangleTable where AnnoationID=@AnnotationID select result=1; END ELSE IF(@shape='pencil') BEGIN Insert into PencilTable(AnnoationID,x1,y1,cord) select @NewAnnotationID ,x1 ,y1 ,cord from PencilTable where AnnoationID=@AnnotationID select result=1; END END GO

getText()