webdriver无法点击Firefox中的超链接 [英] webdriver is not able to click on a hyperlink in firefox

查看:194
本文介绍了webdriver无法点击Firefox中的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

package testproject;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class WeblinkTest {

    public static void main(String[] args) throws InterruptedException {
    // Creating a fierfox driver/window
    WebDriver driver= new FirefoxDriver();
    //Assigning address of the webpage which you want to check
    driver.get("https://www.google.co.in/");
    Thread.sleep(2000);
    //Creating and Identifing--By.xpath the element on which you want testing
    WebElement wb1= driver.findElement(By.xpath(".//*[@id='gb']/div[1]/div[1]/div[1]/div[2]"));
    wb1.click();
    Thread.sleep(2000);
    }

}

今天我试图测试Google首页(www.google.co.in)上提供的gmail链接。我可以启动一个fierfox窗口,也可以做第一步,把我带到谷歌的首页,但之后,没有任何事情发生,我没有得到任何运行时错误或从日食的任何例外。不知道webdriver是怎么回事。
我正在面临一个我已经在stakwave上发布的程序的问题,所以如果你可以请看看这个链接 -

Today i was trying to test a gmail link which is available on Google homepage(www.google.co.in). I am able to launch a fierfox window and also it is able to do the first step which is taking me to google homepage but after that nothing is happening neither i am getting any run time error or any exception from eclipse. Don't know what is going on with the webdriver. I was facing problem with one more program which i already posted on stakwave so if u can then please have a look at this link-Why my test is throwing Exception-Unable to locate element in webdriver?

推荐答案

我在Jan发布了这个问题,说网络驱动程序无法单击超链接,现在我得到了解决方案。
实际上超链接的xpath不准确。
我用过这个xpath-
.//*[@id='gb']/div[1]/div[1]/div[1]/div[2]

I have posted this question in Jan saying that the web-driver was not able to click on the hyperlink and just now i got the solution. Actually the xpath for the hyperlink was not accurate. I had used this xpath- .//*[@id='gb']/div[1]/div[1]/div[1]/div[2] which was locating the logo but not the button.

今天我更改了
。//*[@id='gb']/div[1 ] / div [1] / div [1] / div [2] / a
,现在它的工作完全正常。

Today i changed it by .//*[@id='gb']/div[1]/div[1]/div[1]/div[2]/a and now its working absolutely fine.

请不要生气对我来说,因为我正在通过我从论坛那里提出的问题,发现了这个问题。我得到了解决问题的方法,这就是为什么我正在分享这个问题。

Please don't be angry on me because i was going through the questions which i had asked from the forum and found this question. I got the solution for the problem thats why i am sharing this.

这篇关于webdriver无法点击Firefox中的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆