提问人:Salih_Can 提问时间:11/1/2023 更新时间:11/1/2023 访问量:46
c# selenium whatsapp 网页
c# selenium whatsapp Web
问:
我正在用 c# 编写自动化,以将消息、照片和 pdf 发送到按下按钮时输入的号码,我输入文本框电话号码并按下按钮,网站打开,但如果您想打开 whatsapp 的应用程序,chrome 会发送警报,我想按下取消按钮,但无论我做什么,
我需要你的帮助,谢谢
IAlert 警报 = 驱动程序。SwitchTo() 中。警报(); 警报。解雇(); 不起作用
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
.
.
.
public void button2_Click(object sender, EventArgs e)
{
string telefonNumarasi = maskedTextBox1.Text;
telefonNumarasi = telefonNumarasi.Replace("(", "").Replace(")", "").Replace(" ", "").Replace("-", "");
string temizTelefonNumarasi = telefonNumarasi;
label1.Text = temizTelefonNumarasi;
BASE_URL2 = "https://api.whatsapp.com/send/?phone=90" + temizTelefonNumarasi + "&text&type=phone_number&app_absent=0";
IWebDriver driver = new ChromeDriver();
driver.Url = BASE_URL2;
driver.Navigate().GoToUrl(BASE_URL2);
driver.WaitForPageLoad();
try
{
//IAlert alert = driver.SwitchTo().Alert();
//alert.Dismiss();
IWebElement sohbeteBasla = driver.FindElement(By.XPath("//*[@id=\"action-button\"]"));
sohbeteBasla.Click();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public static string BASE_URL2 { get; set; } = "https://api.whatsapp.com/send/?phone=" +123 + "&text&type=phone_number&app_absent=0";
答: 暂无答案
评论