硒不选择小跨度

时间:2017-06-14 13:47:19

标签: javascript java html selenium firefox

我们在页面上有这个,甚至认为其他一切都有效,我们不能选择这个,我们最好的假设是这是用javaScript制作的。希望你能看到我们是初学者。

technical attributes 1

我们想选择第二个范围 -

technical attributes 2

我们正在使用此代码来达到这一点。

package testProjekt2; 
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

public class testClass2 {
    public static void main(String[] args) throws Exception{
        System.setProperty("webdriver.gecko.driver", "C:\\Selenium-java-3.0.1\\geckodriver.exe");
        ProfilesIni profile = new ProfilesIni();
           // this will create an object for the Firefox profile
        FirefoxProfile myprofile = profile.getProfile("default");
           // this will Initialize the Firefox driver
        WebDriver driver = new FirefoxDriver(myprofile);
         driver.get("https://tests.com:9000/tests");
         Thread.sleep(1000);
         //login here
         driver.findElement(By.xpath(".//*[@id='login']")).click();
         driver.findElement(By.xpath(".//*[@id='login']")).sendKeys("cfadmin");
         driver.findElement(By.xpath(".//*[@id='password']")).click();
         driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("20lipim18");
         driver.findElement(By.xpath(".//*[@id='btnlogin']")).click();
         Thread.sleep(5000);
         // Search for entities
         driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_txtAttr_1_22']")).click();
         Thread.sleep(5000);
         driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_txtAttr_1_22']")).sendKeys("LTR*");
         Thread.sleep(5000);
         driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i0_btnSearch']")).click();
         Thread.sleep(7000);
         //  chose one entity (first)
        // driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i1_RSGrid1_ctl00_ctl04_1_ec20e4e5-4fd1-4963-becb-9087db26af74_CheckBox']")).click();
         driver.findElement(By.xpath(".//*

[@id='panelBarMiddleSearchPanels_i1_RSGrid1_ctl00__0']/td[1]/span[1]")).click();
         driver.findElement(By.xpath(".//*
[@id='panelBarMiddleSearchPanels_i1_RSGrid1_ctl00__1']/td[1]/span[1]")).click();
         Thread.sleep(5000);
      // Open Bulk Edit here
         driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i1_RSToolBar1']/div/div/div/ul/li[1]/a/span/span/span")).click();
         Thread.sleep(5000);

         driver.findElement(By.xpath(".//*[@id='form1']/div[1]/div/ul/li[2]/a/span")).click();
         driver.findElement(By.xpath(".//*[@id='form1']/div[1]/div/ul/li[2]/a/span")).click();
         Thread.sleep(7000);
         String winHandleBefore = driver.getWindowHandle();  // save current window
         for(String winHandle : driver.getWindowHandles()){
                driver.switchTo().window(winHandle);
            }  // switch to bulk edit window
         // Bulk Edit Window
         driver.findElement(By.xpath(".//*[@id='btnEditTemplate']")).click();
         Thread.sleep(7000);
         driver.findElement(By.xpath(".//*[@id='ui-accordion-accordion-header-1']")).click();
         driver.findElement(By.xpath(".//*[@id='jqg_techAttrGrid_5142']")).click();
     driver.findElement(By.xpath(".//*[@id='jqg_techAttrGrid_5149']")).click();
     driver.findElement(By.xpath(".//*[@id='btnBulkEditNext']")).click();
     Thread.sleep(2000);
     driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57338_5142']")).click();
     String oldValue = driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57338_5142']")).getText();
     //SAve value, here 2, change to 20
     driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57338_5142']")).sendKeys("20");
     driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57338_5149']")).click();
     String oldValue2 = driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57338_5149']")).getText();
     //SAve value, here 3, change to 30
     driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57338_5149']")).sendKeys("30");
     driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57339_5142']")).click();
     String oldValue3 = driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57339_5142']")).getText();
     //SAve value, here 2,5, change to 20,5
     driver.findElement(By.xpath(".//*[@id='CtrlTextRS_CTRL_57339_5142']")).sendKeys("20,5");        
     driver.findElement(By.xpath(".//*[@id='mainGridButtonsContainer']/input[3]")).click();
     Thread.sleep(3000);
     driver.switchTo().window(winHandleBefore);  //back to first
     //check value
     Thread.sleep(3000);
     // open Entity editor
     driver.findElement(By.xpath(".//*[@id='panelBarMiddleSearchPanels_i1_RSGrid1_ctl00__0']/td[2]/a")).click();
     Thread.sleep(5000);
     driver.findElement(By.xpath(".//*[@id='tblMain']/tbody/tr[5]/td[5]/img[3]")).click(); // show history
         driver.findElement(By.xpath(".//*[@id='btnClose']")).click();  //close history
         driver.findElement(By.xpath(".//*[@id='NavigationRadPanelBar_i2_i0_trvStandardView']/ul/li[3]/div/span[2]")).click();
         //driver.findElement(By.xpath(".//*[@id='NavigationRadPanelBar_i2_i0_trvStandardView']/ul/li[3]/div/span[2]")).click();
         driver.findElement(By.xpath(".//*[@id='NavigationRadPanelBar_i2_i0_trvStandardView']/ul/li[3]/ul/li[3]/div/span[2]")).click();
         Thread.sleep(3000);
       //  driver.findElement(By.xpath(".//*[@id='lnkOrgCatalog']")).click();
        // driver.findElement(By.xpath(".//*[@id='cboOrg_DropDown']/div/ul/li[2]/a/span")).click();
        // driver.findElement(By.xpath(".//*[@id='btnSave']")).click();

    }
}

任何建议/建议都会受到欢迎,但我们的问题的答案就是这里的重点。问题是我们如何从技术属性组中选择第二个跨度?或者我们如何点击小号加号并打开一个小的下拉菜单?

EDITED: 页面的HTML:

                                    <ul class="rtUL rtLines">
                                        <li class="rtLI rtFirst"><div class="rtTop">
                                            <span class="rtSp"></span><img src="leaf.jpg" alt="Entity Metadata" class="rtImg"><span title="Entity Metadata" class="rtIn">Entity Metadata</span>
                                        </div></li><li class="rtLI"><div class="rtMid">
                                            <span class="rtSp"></span><span class="rtMinus"></span><img src="leaf.jpg" alt="Common Attributes" class="rtImg"><span title="Common Attributes" class="rtIn">Common Attributes</span>
                                        </div><ul class="rtUL">
                                            <li class="rtLI"><div class="rtTop">
                                                <span class="rtSp"></span><img src="leaf.jpg" alt="All" class="rtImg"><span title="All" class="rtIn">All</span>
                                            </div></li><li class="rtLI"><div class="rtMid rtSelected">
                                                <span class="rtSp"></span><img src="leaf.jpg" alt="daten" class="rtImg"><span title="daten" class="rtIn">daten</span>
                                            </div></li><li class="rtLI"><div class="rtMid">
                                                <span class="rtSp"></span><img src="leaf.jpg" alt="Daten" class="rtImg"><span title="Daten" class="rtIn">Daten</span>
                                            </div></li><li class="rtLI rtLast"><div class="rtBot">
                                                <span class="rtSp"></span><img src="leaf.jpg" alt="OMS" class="rtImg"><span title="OMS" class="rtIn"> OMS</span>
                                            </div></li>
                                        </ul></li><li class="rtLI"><div class="rtMid">
                                            <span class="rtSp"></span><span class="rtPlus"></span><img src="leaf.jpg" alt="Technical Attributes" class="rtImg"><span title="Technical Attributes" class="rtIn">Technical Attributes</span>
                                        </div><ul class="rtUL" style="display:none;">
                                            <li class="rtLI rtLast"><div class="rtBot">
                                                <span class="rtSp"></span><img src="leaf.jpg" alt="All" class="rtImg"><span title="All" class="rtIn">All</span>
                                            </div></li>
                                        </ul></li><li class="rtLI rtLast"><div class="rtBot">
                                            <span class="rtSp"></span><span class="rtPlus"></span><img src="leaf.jpg" alt="Relationships" class="rtImg"><span title="Relationships" class="rtIn">Relationships</span>
                                        </div></li>
                                    </ul>

0 个答案:

没有答案