我有一些URL,如「https://some.url.ru/new-token」。我需要將其更改爲「http://some.url.ru/new-token」(意味着將HTTPS更改爲HTTP)。我無法更改整個網址,因爲每次我獲得新的令牌時。 (Selenium,Java)。我如何更改url鏈接並將其與硒一起使用
所以,我的問題:
我得到的網址:driver.getCurrentUrl();
然後我需要改變它 - 將HTTPS更改爲HTTP:如何?
我需要使用新的URL:如何?
我找到了解決辦法:
StringBuffer newUrl = new StringBuffer(driver.getCurrentUrl());
newUrl.deleteCharAt(4); //4 - it's number of symbol what should cut, first symbol have number "0"
driver.get(String.valueOf(newUrl)); //there url would be without 5th symbol.
所以:NOW質疑仍停留的兩個一: 「一些」 到 「另一個」 例如,在如何變化?
是y我們的問題與https安全使用網址,但你想要得到它使用http?你的問題嚴重違反了網絡安全!請通過適當的研究來更新問題。 [檢查如何在SO問](http://www.stackoverflow.com/help/how-to-ask) –
@GirishSortur我的問題與安全無關。有時候我需要改變部分,比如「some」到「another」(例如「https://some.url.ru/new-token」)。 – Lzhelis
是否要取URL,並將其改爲http然後'.get(url)'。或者更改'href'併發送點擊操作? –