【问题标题】:Selenium web Driver retrieve responseSelenium web Driver 检索响应
【发布时间】:2016-12-25 03:12:17
【问题描述】:

如何检索在 selenium web drive 中执行脚本后在浏览器中生成的响应文本。在上图中,我要检索带下划线的响应并将其存储在字符串中。 //打开网页 driver = new ChromeDriver();

        System.setProperty("webdriver.chrome.driver", "/usr/local/share/chromedriver");
        driver.get(Mymark.str);

//Opening the login page
        WebElement login= driver.findElement
       (By.xpath("//a[text()='Log in']"));

     login.click();

// Enter Username 
     WebElement Usrnm=driver.findElement
       (By.xpath("//div[@id='mainContainer']//mymark-login[@class='x-scope mymark-login-0']//input[@name='uname']"));
     Usrnm.sendKeys("nayazjh");


//Enter Password
    WebElement Pswd= driver.findElement
      (By.xpath("//div[@class='content']//div[@class='loginlayout layout vertical justified style-scope mymark-login']//input[@name='password']"));
    Pswd.sendKeys("doordie");


 //click on remember me button
         driver.findElement(By.xpath( "//div[@id='toggleButton']")).click();

 //Click on login button   
        WebElement logIn= driver.findElement
        (By.xpath("//div[@class='lsubmitarea style-scope mymark-login']//paper-button[text()='Log in']"));
     logIn.click();

     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

     driver.findElement
     (By.xpath("//paper-button[text()='Add Bookmark Group ']")).click();



     driver.findElement
     (By.xpath("//paper-dialog[@id='addgroupdialog']//input[@id='input']")).sendKeys("selenium71");



   element =  driver.findElement
     (By.xpath("//paper-dialog[@id='addgroupdialog']//div[@class='adddialogsubmit style-scope mymark-addgroup']" +
            "//paper-button[@id='addgroupbutton']"));
      element.click();


here i need a code to retrieve the response in java 




}

1

上图显示了我想使用 selenium 或 java 得到的响应 在 selenium web drive 中执行脚本后如何检索浏览器中生成的响应文本。在上图中,我要检索带下划线的响应并将其存储在字符串中。

【问题讨论】:

标签: java selenium


【解决方案1】:

据我所知,硒不可能得到实际响应。

Selenium 构建在“顶部”。它不能直接控制浏览器如何与服务器交互,也不应该支持这种控制。

Selenium 被认为是一个 ui 自动化框架,即单击和断言 ui 状态。它并不是为了拦截浏览器-服务器通信。

【讨论】:

    猜你喜欢
    • 2013-03-25
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    相关资源
    最近更新 更多