2017-06-28 74 views
-2

RobotFramework是否有任何方式找到鏈接的URL,然後粘貼到同一個瀏覽器並轉到同一個窗口中。該鏈接存在於第一頁上的按鈕/鏈接中。RobotFramework:如何獲取鏈接的URL

的原因,我問的是,因爲它會打開一個新窗口(這是我不希望它做的)

回答

3

您可以使用Get element attribute獲得href屬性的值。

這裏是使用XPath找到元件的例子:

*** Settings *** 
Library Selenium2Library 

Suite Setup  open browser about:blank chrome 
Suite Teardown close all browsers 

*** Test cases *** 
Example 
    go to http://www.example.com 
    ${url}= get element attribute xpath=//a[text()='More information...']@href 
    Should be equal ${url} http://www.iana.org/domains/example