我试图捕获在我的Java类中的main中抛出的异常.
我的主要代码:
public static void main(String[] args){
new something();
throw new RuntimeException();
}
Run Code Online (Sandbox Code Playgroud)
在我的方面,我已经创建了两个,after() returning: execution(* main(*)) { advice}并 after() throwing(Exception e): execution(* main(*)) { advice }找出是否在主要或不是抛出异常,以便在每个建议上做一些不同的事情.
请注意,在第二个内部,我在输出中打印e异常使用:
System.out.println("Threw an exception: " + e + "Joinpoint: " + thisJoinPoint.getSignature().toString());
Run Code Online (Sandbox Code Playgroud)
问题是,即使我在main中抛出一个异常,我可以从输出中看到匹配的切入点是第二个(输出:) Threw an exception: java.lang.RuntimeExceptionJoinpoint: void main(String[])
,我仍然在输出中得到这个错误:
Exception in thread "main" java.lang.RuntimeException
at main(C.java:24)
Run Code Online (Sandbox Code Playgroud)
所以,据我所知,我没有抓住异常,我刚刚发现在main中发生异常.
有没有办法可以在不必使用的情况下捕获此异常around()?
我使用的是 Windows 操作系统,在 Cygwin 中输入:wish -f ispin.tcl打开 ispin 界面。我打开一个文件test.pml,其中包含:
byte state = 2;
proctype A()
{ (state == 1) -> state = 3
}
proctype B()
{ state = state - 1
}
init
{ run A(); run B()
}
Run Code Online (Sandbox Code Playgroud)
之后,我使用随机方式运行它,种子 = 123。结果打印在输出中,没有问题:
0: proc - (:root:) creates proc 0 (:init:)
Starting A with pid 1
1: proc 0 (:init::1) creates proc 1 (A)
1: proc 0 (:init::1) test.pml:12 (state 1) [(run A())]
Starting B with …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Python和Selenium拖放。
我有两个带有行的容器,这些行指示文件名,并且通过拖放操作,我想将一个文件从第一个容器传输到第二个容器。
我在互联网上看到硒和拖放库存在一些问题,我不确定如何使这项工作有效。
由于浏览器和驱动程序的版本起着重要作用,请查看我使用的浏览器和驱动程序:

我尝试拖放的方式如下:
time.sleep(15)
source_element = self.browser.find_element_by_css_selector('#transfer-tape-listing-nst0 > tbody > tr.file.transfer-tape-item.ui-draggable.ui-draggable-handle > td.listing-name')
dest_element = self.browser.find_element_by_css_selector('#transfer-location-listing > tbody > tr:nth-child(1) > td.listing-name.ui-droppable > span.listing-name-label')
ActionChains(self.browser).drag_and_drop(source_element, dest_element).perform()
Run Code Online (Sandbox Code Playgroud)
我的驱动程序具有以下配置:
def set_up_browser():
display = Display(visible=0, size=(1200, 800))
display.start()
selected_browser = config_section_map('Test')['browser']
browser = ''
if selected_browser == 'Firefox':
opts = FirefoxOptions()
opts.set_headless(headless=False)
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.privatebrowsing.autostart", False)
firefox_profile.set_preference("marionette", True) # remove if causing issues
browser = webdriver.Firefox(executable_path="/usr/bin/drivers/geckodriver", firefox_profile=firefox_profile, firefox_options=opts)
elif selected_browser == 'Chrome':
opts = ChromeOptions()
opts.set_headless(headless=False)
opts.add_argument("--no-sandbox")
opts.add_argument("--incognito")
browser …Run Code Online (Sandbox Code Playgroud)