第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

如何使用 Selenium c# 將 url 從剪貼板粘貼到 Chrome 中的地址欄

如何使用 Selenium c# 將 url 從剪貼板粘貼到 Chrome 中的地址欄

C#
藍(lán)山帝景 2021-08-07 17:30:42
我有一個警告框,它在文本輸入?yún)^(qū)域顯示一個 URL,并將鏈接復(fù)制到剪貼板。我希望能夠打開一個新選項卡,并將 URL 粘貼到地址欄中。我努力了 :var generatedLink = System.Windows.Forms.Clipboard.GetText();_chromeDriver.Navigate().GoToUrl(generatedLink);生成的鏈接返回“”我也試過:嘗試 1:((IJavaScriptExecutor)_chromeDriver).ExecuteScript("window.open();");List<String> tabs = new List<String>(_chromeDriver.WindowHandles);_chromeDriver.SwitchTo().Window(tabs[1]);           _chromeDriver.FindElement(By.XPath("//body")).SendKeys(Keys.Control + "l");_chromeDriver.FindElement(By.XPath("//body")).SendKeys(Keys.Control + "v");SendKeys(Keys.Control + "l") 沒有像它應(yīng)該的那樣選擇地址欄SendKeys(Keys.Control + "v") 不粘貼文本我知道文本被復(fù)制了,因為當(dāng)我調(diào)試測試時,我可以將復(fù)制的文本粘貼到記事本中而不會出現(xiàn)任何問題。以下是復(fù)制發(fā)生的地方:const url = window.location.host + urlPattern.stringify(newUrlParameters) + queryString;   (navigator as any).clipboard.writeText(url)     .then(() => window.prompt('Link copied to clipboard!', url))     .catch(() => window.prompt('Copy to clipboard: Ctrl+C, Enter', url)); 
查看完整描述

2 回答

?
當(dāng)年話下

TA貢獻(xiàn)1890條經(jīng)驗 獲得超9個贊

如果要將url設(shè)置為地址欄,解決方法如下:

((IJavaScriptExecutor)Driver).ExecuteScript("navigator.clipboard.readText().then(text => window.location.replace(text));");

或使用TextCopy 包

Driver.Navigate().GoToUrl(new TextCopy.Clipboard().GetText());


查看完整回答
反對 回復(fù) 2021-08-07
  • 2 回答
  • 0 關(guān)注
  • 459 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號