XPath or CSS in Selenium RC with Java is not working

前端 未结 3 1963
Happy的楠姐
Happy的楠姐 2021-01-16 05:01

I am trying to automate the following scenario with selenium RC:

  1. Open Google home page and enter \"Software\" in search box and then click on search button.
相关标签:
3条回答
  • 2021-01-16 05:21

    there must be pause ( pause (1) ) or waitForElementPresent between 2 clicks here is working sample for phpUnit. Strange, but clickAndWait does'n work

    $this->open("/");
    $this->type("q", "software");
    $this->click("btnG");
    for ($second = 0; ; $second++) {
        if ($second >= 60) $this->fail("timeout");
        try {
            if ($this->isElementPresent("//a[@class='l']")) break;
        } catch (Exception $e) {}
        sleep(1);
    }
    
    $this->click("//a[@class='l']");
    
    0 讨论(0)
  • 2021-01-16 05:32

    Try this xpath (//a[@class="l"])[1]

    0 讨论(0)
  • 2021-01-16 05:48

    Just a side note, Google has a ban on automated queries. I was using Google to test when I was new to testing, now I use our own server.

    What you are looking for is this:

    //a[contains(text(), 'software')] 
    

    This selects the first link with "software" in the link text.

    0 讨论(0)
提交回复
热议问题