尝试在具有自己的滚动条的框中滚动。尝试了很多方法,要么失败,要么不够好。
这是滚动条的 html
<div id="mCSB_2_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 30px; display: block; height: 340px; max-height: 679.6px; top: 0px;" xpath="1"><div class="mCSB_dragger_bar" style="line-height: 30px;"></div></div>
Run Code Online (Sandbox Code Playgroud)
当“顶部”值上升或下降时允许滚动。滚动条当然也会下降。一直试图模仿这一点,但无济于事
到目前为止的一些尝试
scrollbar =driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']")
A = ActionChains(driver1).move_to_element(scrollbar)
A.perform()
A = ActionChains(driver1)
A.perform()
W = driver1.find_element(By.CSS_SELECTOR,".visible-list > .row:nth-child(4)> .investment-item")
W.location_once_scrolled_into_view
Run Code Online (Sandbox Code Playgroud)
scrollbar =driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").get_attribute("style")
newscrollbar = str(scrollbar).replace("top: 0px","top: -100px")
driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").__setattr__("style",newscrollbar)
Run Code Online (Sandbox Code Playgroud)
scrollbar =driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").get_attribute("style")
newscrollbar = str(scrollbar).replace("top: 0px","top: -100px")
A = driver1.create_web_element(newscrollbar)
driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").__setattr__("style",A)
Run Code Online (Sandbox Code Playgroud)
我尝试了很多方法但无济于事..此链接有更多详细信息
使用 Selenium Python 通过编辑属性来使用滚动条
先感谢您
这是一些查看它的方法
A = driver1.find_element(By.XPATH,"//div[@id='mCSB_2_dragger_vertical']").get_attribute("style") …Run Code Online (Sandbox Code Playgroud) 所以我有一些代码可以访问网站的 html,但只能在 Visualstudios.Framework for c# 中将此代码输入到 app.config 中。
<system.net> <defaultProxy useDefaultCredentials="true" /> </system.net>
Run Code Online (Sandbox Code Playgroud)
ps >< 之间的下一行
但我需要此代码在 .CORE 而不是 .FRAMEWORK 中工作,但它给出了此错误。
System.Net.WebException:“远程服务器返回错误:(407)需要代理身份验证。”
我尝试通过从解决方案资源管理器创建 app.config 来解决它,但它是否有效?互联网上的所有答案要么太复杂,要么显示我在 .FRAMEWORK 的 app.config 中放入了一点代码这不适用于 .Core
代码作为起点。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = null;
if (response.CharacterSet == null)
{
readStream = new StreamReader(receiveStream);
Console.WriteLine("Sorry , somethings faulty");
}
else
{
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
readStream.ToString();
// Console.WriteLine(readStream);
}
string ImpureTexta = …Run Code Online (Sandbox Code Playgroud)