简体   繁体   English

硒测试用例/套件

[英]Selenium Test Case/Suite

My Selenium Test Case and Test Suite is not working properly, for some reason when I play each test case separately, it works, however, when I play the whole thing together, it says: 'Element ... not found' and also, if I add both test cases to a new test case and play this new test case, it doesn't work. 我的Selenium测试用例和测试套件无法正常工作,由于某些原因,当我分别测试每个测试用例时,它可以工作,但是,当我一起玩整个过程时,它说: “找不到元素...”如果我将两个测试用例都添加到新的测试用例中并播放此新的测试用例,则无法正常工作。 I am assuming my first test case is fine as that always works, but it gets the element not found error at this point, and I have tried other ways as well: 我假设我的第一个测试用例很好,因为它总是可以正常工作,但是此时它会导致元素未找到错误,并且我也尝试了其他方法:

<tr>
    <td>click</td>
    <td>//div[@class='btn_sel_text' and contains(., 'Volume Entry')]</td>
    <td></td>
</tr>

I also tried replacing the '//div' with: 我也尝试过将'// div'替换为:

css=.btn_sel_text:contains('Volume Entry')

however that didn't work either. 但是那也不起作用。 Can anyone please explain why it doesn't work when I run the whole thing together, however, if I simply run the //div or the 'css' on it's own it does work. 谁能解释一下为什么当我一起运行整个程序时它不起作用,但是,如果我自己单独运行//div或'css',它确实可以工作。

put a pause before click. 在点击之前先停顿一下。

command:pause 命令:暂停

Target:3000 目标:3000

Try it,Thank you. 试试吧,谢谢。

Find Xpath of that element using firepath. 使用firepath查找该元素的Xpath。 with Xpath of element you can click on it. 使用元素的Xpath可以单击它。 do this & let me know your problem is solved or not 这样做并让我知道您的问题已解决

<tr>
<td>pause</td>
<td></td>
<td>1500</td>
</tr>
<tr>
<td>click</td>
<td>Xpath of the element </td>
<td></td>
</tr>

In trying to debug this problem for myself, I found that if I had two test cases that worked individually and then when I ran them together in a test suite a link/button could not be found in the second test case, the solution was actually to modify the FIRST test case. 在尝试为我自己调试此问题时,我发现如果我有两个单独工作的测试用例,然后在一个测试套件中一起运行它们时,在第二个测试用例中找不到链接/按钮。修改FIRST测试用例。

If you have more than two test cases, try changing the order around so that there is some other test case immediately following the original first test case. 如果您有两个以上的测试用例,请尝试更改顺序,以便在最初的第一个测试用例之后立即有其他测试用例。 When I tried that, my error moved from the original second test case to the new second test case. 当我尝试这样做时,我的错误从原来的第二个测试用例转移到了新的第二个测试用例。

I don't know exactly why, but it is like Selenium is unable to catch up with the effects of the first test on the browser or something. 我不知道为什么,但是就像Selenium无法赶上浏览器上的第一个测试的效果。 If add, however, a 'pause 5000' followed by a ClickAndWait (to an inocuous link that keeps me on the same page, perhaps) to the end of the first test case, then when the first and second test case are run together in the test suite, the second test case now works. 但是,如果在第一个测试用例的末尾添加“ pause 5000”,然后加上一个ClickAndWait(可能是一个不连续的链接,使我保持在同一页面上),然后在第一个和第二个测试用例一起运行时测试套件,第二个测试用例现在可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM