亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

selenium phantomJS 下載自定義OCR圖片(aspx擴展)

selenium phantomJS 下載自定義OCR圖片(aspx擴展)

繁星coding 2021-10-06 09:44:09
我有一個由用戶名、密碼和安全碼組成的登錄屏幕。我的目標是使用selenium、phantonJs等技術,將登錄界面的OCR代碼作為圖片下載到電腦上。但是,如以下代碼所述,該標記具有 src aspx 擴展名。因此,當我使用 webclient 調用此 src 中的 aspx 路徑時,會下降不同的 OCR 圖像。我的目標只是將屏幕上的代碼作為圖片下載到我的計算機上 我該怎么做?謝謝[![<div>                            <fieldset>                                <div class="form-group">                                </div>                                <div class="form-group">                                    <input name="txtLoginName" type="text" id="txtLoginName" class="form-control" ><span id="RequiredFieldValidator1">*</span>                                </div>                                <div class="form-group">                                    <input name="txtPassword" type="password" id="txtPassword" class="form-control" ><span id="RequiredFieldValidator2" >*</span>                                </div>                                <div>                                    <img id="imgCap" src="./login_files/RetCap.aspx" style="height:30px;width:100px;border-width:0px;">                                    <input name="txtCap" type="text" id="txtCap" class="form-control" >                                </div></div>][1]][1]
查看完整描述

1 回答

?
收到一只叮咚

TA貢獻1821條經驗 獲得超5個贊

您可以在該元素上截取屏幕截圖并使用FileUtils.copyFile()from lib保存它Apache Commons IO(這里是 lib 存儲庫的鏈接,您可以選擇直接下載為 jar)


這是您可以在特定元素上截取屏幕截圖的方式。


WebElement elem = driver.findElement(By.xpath("//*[@id='imgCap']"));


File scrFile = ((TakesScreenshot)elem).getScreenshotAs(OutputType.FILE);


FileUtils.copyFile(scrFile, new File( "path/where/to/save.jpg" ));

PS:如果你想截圖到整個瀏覽器,更改(TakesScreenshot)elem為driver


查看完整回答
反對 回復 2021-10-06
  • 1 回答
  • 0 關注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號