2016-03-30 16 views
0

Wie identifiziere ich die Schaltfläche Schaltfläche klicken? Markup ist dies:Wählen Sie eine Schaltfläche - Webdriver Java

<button class="ProfileClick-actionButton js-actionButton js-actionReClick" data-modal="ProfileClick-reClick" type="button"> 
    <div class="IconContainer js-tooltip" title="ReClick"> 
     <span class="Icon Icon--reClick"></span> 
     <span class="u-hiddenVisually">ReClick</span> 
    </div> 
     <div class="IconTextContainer"> 
     <span class="ProfileClick-actionCount ProfileClick-actionCount--isZero"> 
      <span class="ProfileClick-actionCountForPresentation" aria-hidden="true"></span> 
     </span> 
     </div> 
    </button> 

ich müde dies:

driver.findElement(By.className("js-actionClick")).click(); 

Antwort

0

Sie können eine ID zum button hinzufügen, und verwenden Sie diese ID es zu verweisen.

<button id="myButton" class="ProfileClick-actionButton js-actionButton js-actionReClick" data-modal="ProfileClick-reClick" type="button"> 
    .... 
</button> 

Und in WebDriver würden Sie

Actions actions = new Actions(driver); 
actions.click(driver.findElement(By.id("myButton"))).perform(); 

tun Sie org.openqa.selenium.interactions.Actions

0

Sie Taste

nach Klasse finden importieren müssen
driver.findElement(By.className("js-actionButton")).click(); 
0

wie unten einen XPath verwenden: -

//button[@class='ProfileClick-actionButton js-actionButton js-actionReClick'] 

ODER

//button[@type='button'] 

Code so etwas wie unten: -

driver.findElement(By.xpath("//button[@class='ProfileClick-actionButton js-actionButton js-actionReClick']")).click(); 

ODER

driver.findElement(By.xpath("//button[@type='button']")).click(); 

es Ihnen Hoffnung helfen :)

Verwandte Themen